Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCM push notifications cause 502 Bad Gateway

I have an .Net windows service that sends GCM push notifications via https://android.googleapis.com/gcm/send.

The service periodically sends batches of approximately 10,000 messages at a rate of 10 / second. With each batch, 5 - 10 of the messages will cause a "502 Bad Gateway" response. The messages that generate the 502 always go through with a second try.

Is this normal? Could I be sending too many messages too quickly?

like image 793
Jake Braun Avatar asked Aug 05 '13 14:08

Jake Braun


People also ask

What causes a 502 Bad gateway?

The HTTP 502 - bad gateway error occurs when either: The timeout of the proxy was reached prior to the request completion. If the connection proxy > server drops. When the response from the server is invalid.

What is GCM push notification?

Google Cloud Messaging (GCM) was a mobile notification service developed by Google that enables third-party application developers to send notification data or information from developer-run servers to applications that target the Google Android Operating System, as well as applications or extensions developed for the ...

Is a 502 Bad gateway my fault?

There is a good chance that if you have run into this error message while browsing, you're not at fault. Typically, an Error 502 bad gateway indicates that there is an issue with the website's server, rather than anything on your end.


1 Answers

According to the GCM guide, all 5xx error codes should be treated as temporary errors, and requests that get these errors should be retried :

5xx Errors in the 500-599 range (such as 500 or 503) indicate that there was an internal error in the GCM server while trying to process the request, or that the server is temporarily unavailable (for example, because of timeouts). Sender must retry later, honoring any Retry-After header included in the response. Application servers must implement exponential back-off.

I don't think 10 messages a second is too quick. As long as your code handles this error and retries, I don't think there should be any problem.

like image 142
Eran Avatar answered Oct 19 '22 15:10

Eran