diff --git a/http_client.rst b/http_client.rst index e0a9d6808e3..5c899660b62 100644 --- a/http_client.rst +++ b/http_client.rst @@ -694,9 +694,10 @@ Retry Failed Requests Sometimes, requests fail because of network issues or temporary server errors. Symfony's HttpClient allows to retry failed requests automatically using the :ref:`retry_failed option `. When enabled, -each failed request with an HTTP status of ``423``, ``425``, ``429``, ``500``, -``502``, ``503``, ``504``, ``507``, or ``510`` is retried up to 3 times, with an -exponential delay between retries (first retry = 1 second; third retry: 4 seconds). +each failed request with an HTTP status of ``423``, ``425``, ``429``, ``502``, +``503`` or with an `idempotent method`_ and a HTTP status of ``500``, ``504``, +``507`` or ``510`` is retried up to 3 times, with an exponential delay between +retries (first retry = 1 second; third retry: 4 seconds). Check out the full list of configurable :ref:`retry_failed options ` to learn how to tweak each of them to fit your application needs. @@ -1609,3 +1610,4 @@ Then configure Symfony to use your callback: .. _`cURL options`: https://www.php.net/manual/en/function.curl-setopt.php .. _`Server-sent events`: https://html.spec.whatwg.org/multipage/server-sent-events.html .. _`EventSource`: https://www.w3.org/TR/eventsource/#eventsource +.. _`idempotent method`: https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods_and_web_applications diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index a3d6e9fd95a..b8b0a7887d6 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -779,7 +779,10 @@ will automatically retry failed HTTP requests. # ... retry_failed: # retry_strategy: app.custom_strategy - http_codes: [429, 500] + http_codes: + 0: ['GET', 'HEAD'] # retry network errors if request method is GET or HEAD + 429: true # retry all responses with 429 status code + 500: ['GET', 'HEAD'] max_retries: 2 delay: 1000 multiplier: 3 @@ -923,7 +926,7 @@ value must use the format ``['header-name' => 'value0, value1, ...']``. http_codes .......... -**type**: ``array`` **default**: ``[423, 425, 429, 500, 502, 503, 504, 507, 510]`` +**type**: ``array`` **default**: :method:`Symfony\\Component\\HttpClient\\Retry\\GenericRetryStrategy::DEFAULT_RETRY_STATUS_CODES` .. versionadded:: 5.2