@@ -913,37 +913,6 @@ If you use for example
913913as the type and name of an argument, autowiring will inject the ``my_api.client ``
914914service into your autowired classes.
915915
916- .. _reference-http-client-retry-failed :
917-
918- By enabling the optional ``retry_failed `` configuration, the HTTP client service
919- will automatically retry failed HTTP requests.
920-
921- .. code-block :: yaml
922-
923- # config/packages/framework.yaml
924- framework :
925- # ...
926- http_client :
927- # ...
928- default_options :
929- retry_failed :
930- # retry_strategy: app.custom_strategy
931- http_codes :
932- 0 : ['GET', 'HEAD'] # retry network errors if request method is GET or HEAD
933- 429 : true # retry all responses with 429 status code
934- 500 : ['GET', 'HEAD']
935- max_retries : 2
936- delay : 1000
937- multiplier : 3
938- max_delay : 5000
939- jitter : 0.3
940-
941- scoped_clients :
942- my_api.client :
943- # ...
944- retry_failed :
945- max_retries : 4
946-
947916auth_basic
948917..........
949918
@@ -1058,6 +1027,8 @@ The minimum version of TLS to accept. The value must be one of the
10581027
10591028 The ``crypto_method `` option was introduced in Symfony 6.3.
10601029
1030+ .. _reference-http-client-retry-delay :
1031+
10611032delay
10621033.....
10631034
@@ -1097,6 +1068,8 @@ headers
10971068An associative array of the HTTP headers added before making the request. This
10981069value must use the format ``['header-name' => 'value0, value1, ...'] ``.
10991070
1071+ .. _reference-http-client-retry-http-codes :
1072+
11001073http_codes
11011074..........
11021075
@@ -1112,6 +1085,8 @@ http_version
11121085The HTTP version to use, typically ``'1.1' `` or ``'2.0' ``. Leave it to ``null ``
11131086to let Symfony select the best version automatically.
11141087
1088+ .. _reference-http-client-retry-jitter :
1089+
11151090jitter
11161091......
11171092
@@ -1139,6 +1114,8 @@ local_pk
11391114The path of a file that contains the `PEM formatted `_ private key of the
11401115certificate defined in the ``local_cert `` option.
11411116
1117+ .. _reference-http-client-retry-max-delay :
1118+
11421119max_delay
11431120.........
11441121
@@ -1173,6 +1150,8 @@ max_redirects
11731150The maximum number of redirects to follow. Use ``0 `` to not follow any
11741151redirection.
11751152
1153+ .. _reference-http-client-retry-max-retries :
1154+
11761155max_retries
11771156...........
11781157
@@ -1181,6 +1160,8 @@ max_retries
11811160The maximum number of retries for failing requests. When the maximum is reached,
11821161the client returns the last received response.
11831162
1163+ .. _reference-http-client-retry-multiplier :
1164+
11841165multiplier
11851166..........
11861167
@@ -1248,6 +1229,54 @@ client and to make your tests easier.
12481229The value of this option is an associative array of ``domain => IP address ``
12491230(e.g ``['symfony.com' => '46.137.106.254', ...] ``).
12501231
1232+ .. _reference-http-client-retry-failed :
1233+
1234+ retry_failed
1235+ ............
1236+
1237+ **type **: ``array ``
1238+
1239+ .. versionadded :: 5.2
1240+
1241+ The ``retry_failed `` option was introduced in Symfony 5.2.
1242+
1243+ This option configures the behavior of the HTTP client when some request fails,
1244+ including which types of requests to retry and how many times. The behavior is
1245+ defined with the following options:
1246+
1247+ * :ref: `delay <reference-http-client-retry-delay >`
1248+ * :ref: `http_codes <reference-http-client-retry-http-codes >`
1249+ * :ref: `jitter <reference-http-client-retry-jitter >`
1250+ * :ref: `max_delay <reference-http-client-retry-max-delay >`
1251+ * :ref: `max_retries <reference-http-client-retry-max-retries >`
1252+ * :ref: `multiplier <reference-http-client-retry-multiplier >`
1253+
1254+ .. code-block :: yaml
1255+
1256+ # config/packages/framework.yaml
1257+ framework :
1258+ # ...
1259+ http_client :
1260+ # ...
1261+ default_options :
1262+ retry_failed :
1263+ # retry_strategy: app.custom_strategy
1264+ http_codes :
1265+ 0 : ['GET', 'HEAD'] # retry network errors if request method is GET or HEAD
1266+ 429 : true # retry all responses with 429 status code
1267+ 500 : ['GET', 'HEAD']
1268+ max_retries : 2
1269+ delay : 1000
1270+ multiplier : 3
1271+ max_delay : 5000
1272+ jitter : 0.3
1273+
1274+ scoped_clients :
1275+ my_api.client :
1276+ # ...
1277+ retry_failed :
1278+ max_retries : 4
1279+
12511280 retry_strategy
12521281..............
12531282
0 commit comments