Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR : exposing Retry-After header #386

Closed
bulletblp4 opened this issue Jun 19, 2020 · 3 comments
Closed

FR : exposing Retry-After header #386

bulletblp4 opened this issue Jun 19, 2020 · 3 comments

Comments

@bulletblp4
Copy link

bulletblp4 commented Jun 19, 2020

As per the documentation, seems like we have to honor the retry after header. But the golang sdk doesn't seem to be exposing it.

  • Firebase SDK version: v3.13.0
@hiranya911
Copy link
Contributor

SDK automatically does that so no additional handling is necessary. But if you really wish to access the headers, the v4 SDK provides the necessary APIs:

https://pkg.go.dev/firebase.google.com/go/v4/errorutils?tab=doc#HTTPResponse
https://firebase.google.com/docs/reference/admin/error-handling#accessing-the-http-response

@bulletblp4
Copy link
Author

bulletblp4 commented Jul 8, 2020

Thanks!
I havent explored the code base, but as per the docmentations

the SDK will respect that when retrying as long as the specified wait duration is not very long

How long is long here. I am asking cause a while ago we encountered a case where gcm/fcm was down for an hour or more. And our queues were stacked up with thousands of messages. Will SDK handle that case aswell ?

@hiranya911
Copy link
Contributor

SDK retires are intended to help recover from transient network and backend errors that are short-lived (in the order of seconds). Therefore the SDK does not retry if the backend server sends an error with Retry-After set to a duration longer than 2 minutes.

// WithDefaultRetryConfig creates a new HTTPClient using the provided client and the default
// RetryConfig.
//
// The default RetryConfig retries requests on all low-level network errors as well as on HTTP
// InternalServerError (500) and ServiceUnavailable (503) errors. Repeatedly failing requests are
// retried up to 4 times with exponential backoff. Retry delay is never longer than 2 minutes.
func WithDefaultRetryConfig(hc *http.Client) *HTTPClient {
twoMinutes := time.Duration(2) * time.Minute
return &HTTPClient{
Client: hc,
RetryConfig: &RetryConfig{
MaxRetries: 4,
CheckForRetry: retryNetworkAndHTTPErrors(
http.StatusInternalServerError,
http.StatusServiceUnavailable,
),
ExpBackoffFactor: 0.5,
MaxDelay: &twoMinutes,
},
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants