You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello I have a use case where I'd like to impose a timeout on my http client with retries. This means that http client's context cancellation should be retryable action. According to my testing it is not:
=== RUN TestRetryableHTTP
2022/05/16 19:18:41 [DEBUG] GET http://127.0.0.1:49948
2022/05/16 19:18:42 [ERR] GET http://127.0.0.1:49948 request failed: Get "http://127.0.0.1:49948": context deadline exceeded
2022/05/16 19:18:42 [DEBUG] GET http://127.0.0.1:49948: retrying in 1s (4 left)
sanehttp_test.go:168: connection droppped from client
sanehttp_test.go:187:
Error Trace: sanehttp_test.go:187
Error: Received unexpected error:
context deadline exceeded
Test: TestRetryableHTTP
sanehttp_test.go:189:
Error Trace: sanehttp_test.go:189
Error: Not equal:
expected: 5
actual : 1
Test: TestRetryableHTTP
--- FAIL: TestRetryableHTTP (1.01s)
You can see there was only 1 attempt and no retries.
I have also tried to use the http client Timeout field instead of context cancellation but it yields the same result.
I was checking the source code and it looks like you are not retrying on errors from client.Do() which is the case. Do you know if there is a way how to make my use case work?
Thank you.
The text was updated successfully, but these errors were encountered:
Also interested in the possibility of having per retry timeouts. Preferably through context so wouldn't need a custom HTTP client for each request with different timeouts.
Where the request context trumps the CheckRetry logic. That makes sense on the surface, but it also makes it impossible (in its current state) to retry based on client timeout settings.
Hello I have a use case where I'd like to impose a timeout on my http client with retries. This means that http client's context cancellation should be retryable action. According to my testing it is not:
Test output:
You can see there was only 1 attempt and no retries.
I have also tried to use the http client
Timeout
field instead of context cancellation but it yields the same result.I was checking the source code and it looks like you are not retrying on errors from
client.Do()
which is the case. Do you know if there is a way how to make my use case work?Thank you.
The text was updated successfully, but these errors were encountered: