node-gcm
node-gcm copied to clipboard
In gcm spec we should respect Retry-After header
Originally by @ghominejad in #92 (but that contained several issues).
Retry-After
is a response header. we can see it in some errors in the 500-599 range. it's a time that we must retry later after that.
https://developer.android.com/google/gcm/server-ref.html
Quoting the relevant section:
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.
Quoting the RFC:
The Retry-After response-header field can be used with a 503 (Service Unavailable) response to indicate how long the service is expected to be unavailable to the requesting client. This field MAY also be used with any 3xx (Redirection) response to indicate the minimum time the user-agent is asked wait before issuing the redirected request. The value of this field can be either an HTTP-date or an integer number of seconds (in decimal) after the time of the response.