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

Retry when service is (tempoarily) unavailable #643

Open
jacobemcken opened this issue Feb 15, 2024 · 3 comments
Open

Retry when service is (tempoarily) unavailable #643

jacobemcken opened this issue Feb 15, 2024 · 3 comments

Comments

@jacobemcken
Copy link

Retries work well with IOExceptions (like timeouts). 👍

I had assumed that retries would also be applied, when a service is reported (temporarily) unavailable like 502, 503 & 504

When reading about the Apache HttpClient, it seems a ServiceUnavailableRetryStrategy exists for the cases mentioned above.

Is it on purpose this is left out of clj-http?

@jacobemcken
Copy link
Author

jacobemcken commented Feb 15, 2024

When receiving a 503 I would expect the code to automatically retry:

(client/request {:url "https://httpbin.org/status/503"
                 :method :get
                 :retry-handler (fn [ex try-count http-context]
                                  (println "Got:" ex)
                                  (if (> try-count 4) false true))})

I read about the ServiceUnavailableRetryStrategy class on a blog:
https://kevcodez.de/posts/2020-09-27-resilient-apache-http-client/

@dakrone
Copy link
Owner

dakrone commented Feb 15, 2024

I don't think we should retry on 5XX responses by default, but it would be fine to expose the ServiceUnavailableRetryStrategy in some way also, if someone wanted to use it.

@agorgl
Copy link

agorgl commented Apr 25, 2024

On the same ship, working with some APIs that sporadically show some 503 responses for a moment, would be great to expose the ServiceUnavailableRetryStrategy in order to allow an :unavailable-handler or something to use this functionality

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

3 participants