@@ -137,11 +137,34 @@ Configuration
137137 * `proxy `_
138138 * `query `_
139139 * `resolve `_
140+
141+ * :ref: `retry_failed <reference-http-client-retry-failed >`
142+
143+ * `backoff_service `_
144+ * `decider_service `_
145+ * :ref: `enabled <reference-http-client-retry-enabled >`
146+ * `delay `_
147+ * `http_codes `_
148+ * `max_delay `_
149+ * `max_retries `_
150+ * `multiplier `_
151+
140152 * `timeout `_
141153 * `max_duration `_
142154 * `verify_host `_
143155 * `verify_peer `_
144156
157+ * :ref: `retry_failed <reference-http-client-retry-failed >`
158+
159+ * `backoff_service `_
160+ * `decider_service `_
161+ * :ref: `enabled <reference-http-client-retry-enabled >`
162+ * `delay `_
163+ * `http_codes `_
164+ * `max_delay `_
165+ * `max_retries `_
166+ * `multiplier `_
167+
145168* `http_method_override `_
146169* `ide `_
147170* :ref: `lock <reference-lock >`
@@ -742,6 +765,33 @@ If you use for example
742765as the type and name of an argument, autowiring will inject the ``my_api.client ``
743766service into your autowired classes.
744767
768+ .. _reference-http-client-retry-failed :
769+
770+ By enabling the optional ``retry_failed `` configuration, the HTTP client service
771+ will automaticaly retry failed HTTP requests.
772+
773+ .. code-block :: yaml
774+
775+ # config/packages/framework.yaml
776+ framework :
777+ # ...
778+ http_client :
779+ # ...
780+ retry_failed :
781+ # backoff_service: app.custom_backoff
782+ # decider_service: app.custom_decider
783+ http_codes : [429, 500]
784+ max_retries : 2
785+ delay : 1000
786+ multiplier : 3
787+ max_delay : 500
788+
789+ scoped_clients :
790+ my_api.client :
791+ # ...
792+ retry_failed :
793+ max_retries : 4
794+
745795 auth_basic
746796..........
747797
@@ -769,6 +819,19 @@ in the `Microsoft NTLM authentication protocol`_. The value of this option must
769819follow the format ``username:password ``. This authentication mechanism requires
770820using the cURL-based transport.
771821
822+ backoff_service
823+ ...............
824+
825+ **type **: ``string ``
826+
827+ The service id used to compute the time to wait between retries. By default, it
828+ uses an instance of
829+ :class: `Symfony\\ Component\\ HttpClient\\ Retry\\ ExponentialBackOff ` configured
830+ with ``delay ``, ``max_delay `` and ``multiplier `` options. This class has to
831+ implement :class: `Symfony\\ Component\\ HttpClient\\ Retry\\ RetryBackOffInterface `.
832+ This options cannot be used along `delay `_, `max_delay `_ or `multiplier `_
833+ options.
834+
772835base_uri
773836........
774837
@@ -837,6 +900,36 @@ ciphers
837900A list of the names of the ciphers allowed for the SSL/TLS connections. They
838901can be separated by colons, commas or spaces (e.g. ``'RC4-SHA:TLS13-AES-128-GCM-SHA256' ``).
839902
903+ decider_service
904+ ...............
905+
906+ **type **: ``string ``
907+
908+ The service id used to decide if a request should be retried. By default, it
909+ uses an instance of
910+ :class: `Symfony\\ Component\\ HttpClient\\ Retry\\ HttpStatusCodeDecider ` configured
911+ with ``http_codes `` options. This class has to
912+ implement :class: `Symfony\\ Component\\ HttpClient\\ Retry\\ RetryDeciderInterface `.
913+ This options cannot be used along `http_codes `_ option.
914+
915+ delay
916+ .....
917+
918+ **type **: ``integer `` **default **: ``1000 ``
919+
920+ The initial delay in milliseconds used to compute the waiting time between
921+ retries. This options cannot be used along `backoff_service `_ option.
922+
923+ .. _reference-http-client-retry-enabled :
924+
925+ enabled
926+ .......
927+
928+ **type **: ``boolean `` **default **: ``false ``
929+
930+ Whether to enable the support for retry failed HTTP request or not.
931+ This setting is automatically set to true when one of the child settings is configured.
932+
840933headers
841934.......
842935
@@ -845,6 +938,14 @@ headers
845938An associative array of the HTTP headers added before making the request. This
846939value must use the format ``['header-name' => header-value, ...] ``.
847940
941+ http_codes
942+ ..........
943+
944+ **type **: ``array `` **default **: ``[423, 425, 429, 500, 502, 503, 504, 507, 510] ``
945+
946+ The list of HTTP status codes that triggers a retry of the request.
947+ This options cannot be used along `decider_service `_ option.
948+
848949http_version
849950............
850951
@@ -870,6 +971,15 @@ local_pk
870971The path of a file that contains the `PEM formatted `_ private key of the
871972certificate defined in the ``local_cert `` option.
872973
974+ max_delay
975+ .........
976+
977+ **type **: ``integer `` **default **: ``0 ``
978+
979+ The maximum amount of milliseconds initial to wait between retries.
980+ Use ``0 `` to not limit the duration.
981+ This options cannot be used along `backoff_service `_ option.
982+
873983max_duration
874984............
875985
@@ -896,6 +1006,22 @@ max_redirects
8961006The maximum number of redirects to follow. Use ``0 `` to not follow any
8971007redirection.
8981008
1009+ max_retries
1010+ ...........
1011+
1012+ **type **: ``integer `` **default **: ``3 ``
1013+
1014+ The maximum number of retries before aborting. When the maximum is reach, the
1015+ client returns the last received responses.
1016+
1017+ multiplier
1018+ ..........
1019+
1020+ **type **: ``float `` **default **: ``2 ``
1021+
1022+ Multiplier to apply to the delay each time a retry occurs.
1023+ This options cannot be used along `backoff_service `_ option.
1024+
8991025no_proxy
9001026........
9011027
0 commit comments