i/o timeout connecting to firebase












0















Yesterday everything was worked as expected in my Go application. I didn't change anything related to firewalls/configurations. Today when I'm trying to send a request to "https://fcm.googleapis.com/fcm/send" I got the next errors:




Post https://fcm.googleapis.com/fcm/send: dial tcp: lookup
fcm.googleapis.com on IP:53: read udp IP:37987->IP:53: i/o timeout




I don't know how this error happen. Firewall configuration still the same. The weird is that If I test locally then it works fine but when I upload to my server I got that error.



NGINX Configuration under Plesk:



server_name mydomain.com;

location /api/v1 {

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

fastcgi_read_timeout 2500;
proxy_connect_timeout 2500;
proxy_send_timeout 2500;
proxy_read_timeout 2500;
send_timeout 2500;
proxy_pass http://localhost:8082/api/v1;
}


UPDATE
Checking the logs I got this from NGINX



499 POST /api/v1/notifications HTTP/1.1


My domain doesnt have a SSL Certificate, can this be the cause of timeout?



UPDATE Code:



client, err := fcm.NewClient("KEY")
if err != nil {
fmt.Println(err)
}

handler.FirebaseClient = client
firebaseNotification := &fcm.Message{
Notification: &fcm.Notification{
Title: notificationData.Title,
Body: notificationData.Body,
},
}
firebaseNotification.RegistrationIDs = notificationData.Tokens

fmt.Println(firebaseNotification)
_, err := FirebaseClient.Send(firebaseNotification)
if err != nil {
fmt.Println(err)
return
}


Send function from the library github.com/appleboy/go-fcm



func (c *Client) send(data byte) (*Response, error) {
// create request
req, err := http.NewRequest("POST", c.endpoint, bytes.NewBuffer(data))
if err != nil {
return nil, err
}

// add headers
req.Header.Add("Authorization", fmt.Sprintf("key=%s", c.apiKey))
req.Header.Add("Content-Type", "application/json")

// execute request
resp, err := c.client.Do(req)
if err != nil {
return nil, connectionError(err.Error())
}
defer resp.Body.Close()

// check response status
if resp.StatusCode != http.StatusOK {
if resp.StatusCode >= http.StatusInternalServerError {
return nil, serverError(fmt.Sprintf("%d error: %s", resp.StatusCode, resp.Status))
}
return nil, fmt.Errorf("%d error: %s", resp.StatusCode, resp.Status)
}

// build return
response := new(Response)
if err := json.NewDecoder(resp.Body).Decode(response); err != nil {
return nil, err
}

return response, nil
}









share|improve this question

























  • *Firewall is disabled in my server.

    – Dex Sebas
    Nov 13 '18 at 22:36











  • Please, show you the operational sequence of your elements (app, nginx, gcm, etc)

    – Aristofanio Garcia
    Nov 13 '18 at 22:59











  • I updated the code

    – Dex Sebas
    Nov 13 '18 at 23:03











  • I dont understand your work. You are forwarding fcm by nginx or you are receiving fcm response by nginx?

    – Aristofanio Garcia
    Nov 14 '18 at 7:37











  • Like jack, let go by parts: error 499 in nginx is configuration fail. Check stackoverflow.com/questions/15613452/…

    – Aristofanio Garcia
    Nov 14 '18 at 7:38
















0















Yesterday everything was worked as expected in my Go application. I didn't change anything related to firewalls/configurations. Today when I'm trying to send a request to "https://fcm.googleapis.com/fcm/send" I got the next errors:




Post https://fcm.googleapis.com/fcm/send: dial tcp: lookup
fcm.googleapis.com on IP:53: read udp IP:37987->IP:53: i/o timeout




I don't know how this error happen. Firewall configuration still the same. The weird is that If I test locally then it works fine but when I upload to my server I got that error.



NGINX Configuration under Plesk:



server_name mydomain.com;

location /api/v1 {

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

fastcgi_read_timeout 2500;
proxy_connect_timeout 2500;
proxy_send_timeout 2500;
proxy_read_timeout 2500;
send_timeout 2500;
proxy_pass http://localhost:8082/api/v1;
}


UPDATE
Checking the logs I got this from NGINX



499 POST /api/v1/notifications HTTP/1.1


My domain doesnt have a SSL Certificate, can this be the cause of timeout?



UPDATE Code:



client, err := fcm.NewClient("KEY")
if err != nil {
fmt.Println(err)
}

handler.FirebaseClient = client
firebaseNotification := &fcm.Message{
Notification: &fcm.Notification{
Title: notificationData.Title,
Body: notificationData.Body,
},
}
firebaseNotification.RegistrationIDs = notificationData.Tokens

fmt.Println(firebaseNotification)
_, err := FirebaseClient.Send(firebaseNotification)
if err != nil {
fmt.Println(err)
return
}


Send function from the library github.com/appleboy/go-fcm



func (c *Client) send(data byte) (*Response, error) {
// create request
req, err := http.NewRequest("POST", c.endpoint, bytes.NewBuffer(data))
if err != nil {
return nil, err
}

// add headers
req.Header.Add("Authorization", fmt.Sprintf("key=%s", c.apiKey))
req.Header.Add("Content-Type", "application/json")

// execute request
resp, err := c.client.Do(req)
if err != nil {
return nil, connectionError(err.Error())
}
defer resp.Body.Close()

// check response status
if resp.StatusCode != http.StatusOK {
if resp.StatusCode >= http.StatusInternalServerError {
return nil, serverError(fmt.Sprintf("%d error: %s", resp.StatusCode, resp.Status))
}
return nil, fmt.Errorf("%d error: %s", resp.StatusCode, resp.Status)
}

// build return
response := new(Response)
if err := json.NewDecoder(resp.Body).Decode(response); err != nil {
return nil, err
}

return response, nil
}









share|improve this question

























  • *Firewall is disabled in my server.

    – Dex Sebas
    Nov 13 '18 at 22:36











  • Please, show you the operational sequence of your elements (app, nginx, gcm, etc)

    – Aristofanio Garcia
    Nov 13 '18 at 22:59











  • I updated the code

    – Dex Sebas
    Nov 13 '18 at 23:03











  • I dont understand your work. You are forwarding fcm by nginx or you are receiving fcm response by nginx?

    – Aristofanio Garcia
    Nov 14 '18 at 7:37











  • Like jack, let go by parts: error 499 in nginx is configuration fail. Check stackoverflow.com/questions/15613452/…

    – Aristofanio Garcia
    Nov 14 '18 at 7:38














0












0








0








Yesterday everything was worked as expected in my Go application. I didn't change anything related to firewalls/configurations. Today when I'm trying to send a request to "https://fcm.googleapis.com/fcm/send" I got the next errors:




Post https://fcm.googleapis.com/fcm/send: dial tcp: lookup
fcm.googleapis.com on IP:53: read udp IP:37987->IP:53: i/o timeout




I don't know how this error happen. Firewall configuration still the same. The weird is that If I test locally then it works fine but when I upload to my server I got that error.



NGINX Configuration under Plesk:



server_name mydomain.com;

location /api/v1 {

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

fastcgi_read_timeout 2500;
proxy_connect_timeout 2500;
proxy_send_timeout 2500;
proxy_read_timeout 2500;
send_timeout 2500;
proxy_pass http://localhost:8082/api/v1;
}


UPDATE
Checking the logs I got this from NGINX



499 POST /api/v1/notifications HTTP/1.1


My domain doesnt have a SSL Certificate, can this be the cause of timeout?



UPDATE Code:



client, err := fcm.NewClient("KEY")
if err != nil {
fmt.Println(err)
}

handler.FirebaseClient = client
firebaseNotification := &fcm.Message{
Notification: &fcm.Notification{
Title: notificationData.Title,
Body: notificationData.Body,
},
}
firebaseNotification.RegistrationIDs = notificationData.Tokens

fmt.Println(firebaseNotification)
_, err := FirebaseClient.Send(firebaseNotification)
if err != nil {
fmt.Println(err)
return
}


Send function from the library github.com/appleboy/go-fcm



func (c *Client) send(data byte) (*Response, error) {
// create request
req, err := http.NewRequest("POST", c.endpoint, bytes.NewBuffer(data))
if err != nil {
return nil, err
}

// add headers
req.Header.Add("Authorization", fmt.Sprintf("key=%s", c.apiKey))
req.Header.Add("Content-Type", "application/json")

// execute request
resp, err := c.client.Do(req)
if err != nil {
return nil, connectionError(err.Error())
}
defer resp.Body.Close()

// check response status
if resp.StatusCode != http.StatusOK {
if resp.StatusCode >= http.StatusInternalServerError {
return nil, serverError(fmt.Sprintf("%d error: %s", resp.StatusCode, resp.Status))
}
return nil, fmt.Errorf("%d error: %s", resp.StatusCode, resp.Status)
}

// build return
response := new(Response)
if err := json.NewDecoder(resp.Body).Decode(response); err != nil {
return nil, err
}

return response, nil
}









share|improve this question
















Yesterday everything was worked as expected in my Go application. I didn't change anything related to firewalls/configurations. Today when I'm trying to send a request to "https://fcm.googleapis.com/fcm/send" I got the next errors:




Post https://fcm.googleapis.com/fcm/send: dial tcp: lookup
fcm.googleapis.com on IP:53: read udp IP:37987->IP:53: i/o timeout




I don't know how this error happen. Firewall configuration still the same. The weird is that If I test locally then it works fine but when I upload to my server I got that error.



NGINX Configuration under Plesk:



server_name mydomain.com;

location /api/v1 {

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

fastcgi_read_timeout 2500;
proxy_connect_timeout 2500;
proxy_send_timeout 2500;
proxy_read_timeout 2500;
send_timeout 2500;
proxy_pass http://localhost:8082/api/v1;
}


UPDATE
Checking the logs I got this from NGINX



499 POST /api/v1/notifications HTTP/1.1


My domain doesnt have a SSL Certificate, can this be the cause of timeout?



UPDATE Code:



client, err := fcm.NewClient("KEY")
if err != nil {
fmt.Println(err)
}

handler.FirebaseClient = client
firebaseNotification := &fcm.Message{
Notification: &fcm.Notification{
Title: notificationData.Title,
Body: notificationData.Body,
},
}
firebaseNotification.RegistrationIDs = notificationData.Tokens

fmt.Println(firebaseNotification)
_, err := FirebaseClient.Send(firebaseNotification)
if err != nil {
fmt.Println(err)
return
}


Send function from the library github.com/appleboy/go-fcm



func (c *Client) send(data byte) (*Response, error) {
// create request
req, err := http.NewRequest("POST", c.endpoint, bytes.NewBuffer(data))
if err != nil {
return nil, err
}

// add headers
req.Header.Add("Authorization", fmt.Sprintf("key=%s", c.apiKey))
req.Header.Add("Content-Type", "application/json")

// execute request
resp, err := c.client.Do(req)
if err != nil {
return nil, connectionError(err.Error())
}
defer resp.Body.Close()

// check response status
if resp.StatusCode != http.StatusOK {
if resp.StatusCode >= http.StatusInternalServerError {
return nil, serverError(fmt.Sprintf("%d error: %s", resp.StatusCode, resp.Status))
}
return nil, fmt.Errorf("%d error: %s", resp.StatusCode, resp.Status)
}

// build return
response := new(Response)
if err := json.NewDecoder(resp.Body).Decode(response); err != nil {
return nil, err
}

return response, nil
}






firebase go server firebase-cloud-messaging






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 8:05









Flimzy

38.1k96597




38.1k96597










asked Nov 13 '18 at 22:06









Dex SebasDex Sebas

107210




107210













  • *Firewall is disabled in my server.

    – Dex Sebas
    Nov 13 '18 at 22:36











  • Please, show you the operational sequence of your elements (app, nginx, gcm, etc)

    – Aristofanio Garcia
    Nov 13 '18 at 22:59











  • I updated the code

    – Dex Sebas
    Nov 13 '18 at 23:03











  • I dont understand your work. You are forwarding fcm by nginx or you are receiving fcm response by nginx?

    – Aristofanio Garcia
    Nov 14 '18 at 7:37











  • Like jack, let go by parts: error 499 in nginx is configuration fail. Check stackoverflow.com/questions/15613452/…

    – Aristofanio Garcia
    Nov 14 '18 at 7:38



















  • *Firewall is disabled in my server.

    – Dex Sebas
    Nov 13 '18 at 22:36











  • Please, show you the operational sequence of your elements (app, nginx, gcm, etc)

    – Aristofanio Garcia
    Nov 13 '18 at 22:59











  • I updated the code

    – Dex Sebas
    Nov 13 '18 at 23:03











  • I dont understand your work. You are forwarding fcm by nginx or you are receiving fcm response by nginx?

    – Aristofanio Garcia
    Nov 14 '18 at 7:37











  • Like jack, let go by parts: error 499 in nginx is configuration fail. Check stackoverflow.com/questions/15613452/…

    – Aristofanio Garcia
    Nov 14 '18 at 7:38

















*Firewall is disabled in my server.

– Dex Sebas
Nov 13 '18 at 22:36





*Firewall is disabled in my server.

– Dex Sebas
Nov 13 '18 at 22:36













Please, show you the operational sequence of your elements (app, nginx, gcm, etc)

– Aristofanio Garcia
Nov 13 '18 at 22:59





Please, show you the operational sequence of your elements (app, nginx, gcm, etc)

– Aristofanio Garcia
Nov 13 '18 at 22:59













I updated the code

– Dex Sebas
Nov 13 '18 at 23:03





I updated the code

– Dex Sebas
Nov 13 '18 at 23:03













I dont understand your work. You are forwarding fcm by nginx or you are receiving fcm response by nginx?

– Aristofanio Garcia
Nov 14 '18 at 7:37





I dont understand your work. You are forwarding fcm by nginx or you are receiving fcm response by nginx?

– Aristofanio Garcia
Nov 14 '18 at 7:37













Like jack, let go by parts: error 499 in nginx is configuration fail. Check stackoverflow.com/questions/15613452/…

– Aristofanio Garcia
Nov 14 '18 at 7:38





Like jack, let go by parts: error 499 in nginx is configuration fail. Check stackoverflow.com/questions/15613452/…

– Aristofanio Garcia
Nov 14 '18 at 7:38












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290224%2fi-o-timeout-connecting-to-firebase%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290224%2fi-o-timeout-connecting-to-firebase%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

List item for chat from Array inside array React Native

Thiostrepton

Jo Brand