Skip to content

Add documentation for retry on idempotent methods #14449

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

Merged
merged 1 commit into from
Oct 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions http_client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <reference-http-client-retry-failed>`. 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 <reference-http-client-retry-failed>`
to learn how to tweak each of them to fit your application needs.
Expand Down Expand Up @@ -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
7 changes: 5 additions & 2 deletions reference/configuration/framework.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down