Skip to content

[HttpClient] Retry_failed - delay doesn't work #59883

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

Open
devmysz opened this issue Feb 28, 2025 · 3 comments
Open

[HttpClient] Retry_failed - delay doesn't work #59883

devmysz opened this issue Feb 28, 2025 · 3 comments

Comments

@devmysz
Copy link

devmysz commented Feb 28, 2025

Symfony version(s) affected

7.1+

Description

I want to retry requests that timed out with a specified delay.
For timeout=3 and max_retries=3, when I try to send a request to the webhookX endpoint (which includes a sleep to simulate a timeout exception), I receive the following log entries:

[2025-02-27T21:57:44.851034+00:00] http_client.INFO: Try #1 after 5680ms: Idle timeout reached for "http://127.0.0.1:8080/webhookX". {"count":1,"delay":5680} []
[2025-02-27T21:57:44.851414+00:00] http_client.INFO: Request: "POST http://127.0.0.1:8080/webhookX" [] []
[2025-02-27T21:57:47.854169+00:00] http_client.INFO: Try #2 after 15609ms: Idle timeout reached for "http://127.0.0.1:8080/webhookX". {"count":2,"delay":15609} []
[2025-02-27T21:57:47.855437+00:00] http_client.INFO: Request: "POST http://127.0.0.1:8080/webhookX" [] []
[2025-02-27T21:57:50.856308+00:00] http_client.INFO: Try #3 after 37402ms: Idle timeout reached for "http://127.0.0.1:8080/webhookX". {"count":3,"delay":37402} []
[2025-02-27T21:57:50.856729+00:00] http_client.INFO: Request: "POST http://127.0.0.1:8080/webhookX" [] []
[2025-02-27T21:57:53.980913+00:00] app.ERROR: Invalid response from SomeException {"exception":"[object] (App\...........\SomeException(code: 103): Invalid response from ...... at /app/src/.........../SomeException.php:13)\n[previous exception] [object] (Symfony\\Component\\HttpClient\\Exception\\TimeoutException(code: 0): Idle timeout reached for \"http://127.0.0.1:8080/webhookX\". at /app/vendor/symfony/http-client/Chunk/ErrorChunk.php:55)"} []

Even though the context with the pause is set correctly (RetryableHttpClient) and the delay is visible in the logs, it has no effect on the requests.

Please help, I suspect there might be a bug here.

How to reproduce

https://github.com/devmysz/retry-example - small app with instructions (README.md)

Use sleep in some endpoint which you will call, use below config for http-client and make a request:

framework:
     http_client:
         default_options:
             timeout: 3
             retry_failed:
                 http_codes:
                     0: ['POST'] # 0 - network errors
                 max_retries: 3
                 delay: 300000  # milliseconds
                 multiplier: 3
                 jitter: 0.2

Possible Solution

No response

Additional Context

No response

@devmysz devmysz added the Bug label Feb 28, 2025
@alexandre-daubois alexandre-daubois changed the title [http-client] Retry_failed - delay doesn't work [HttpClient] Retry_failed - delay doesn't work Feb 28, 2025
@devmysz
Copy link
Author

devmysz commented Mar 12, 2025

@alexandre-daubois could you finish review (with "reviewed" label)?

@alexandre-daubois
Copy link
Member

alexandre-daubois commented Mar 12, 2025

You may create an example app to reproduce this behavior. This can be a small app with one command that you publicly push on Github with a little readme (such as "launch this command to reproduce"), so maintainers and contributors can clone your reproducer and quickly evaluate/debug it. This would greatly help us to investigate on the problem!

@devmysz
Copy link
Author

devmysz commented Mar 12, 2025

@alexandre-daubois sure, you're welcome: https://github.com/devmysz/retry-example

It looks like the wait time for the request to complete + delay must fit within the timeout setting of the HTTP client (default 60s, 3s in the example), which is contradictory in this case. When the timeout occurs, it means this value has already been reached, and the delay will never take effect.

It works better with other responses, such as 503, but it still won’t wait longer than the timeout. For example, if the timeout is 60s, the request responds with a 503 after 10s, and the delay should be 120s, it will be retried after 50s, not 120s.

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

No branches or pull requests

4 participants