@@ -913,37 +913,6 @@ If you use for example
913
913
as the type and name of an argument, autowiring will inject the ``my_api.client ``
914
914
service into your autowired classes.
915
915
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
-
947
916
auth_basic
948
917
..........
949
918
@@ -1058,6 +1027,8 @@ The minimum version of TLS to accept. The value must be one of the
1058
1027
1059
1028
The ``crypto_method `` option was introduced in Symfony 6.3.
1060
1029
1030
+ .. _reference-http-client-retry-delay :
1031
+
1061
1032
delay
1062
1033
.....
1063
1034
@@ -1097,6 +1068,8 @@ headers
1097
1068
An associative array of the HTTP headers added before making the request. This
1098
1069
value must use the format ``['header-name' => 'value0, value1, ...'] ``.
1099
1070
1071
+ .. _reference-http-client-retry-http-codes :
1072
+
1100
1073
http_codes
1101
1074
..........
1102
1075
@@ -1112,6 +1085,8 @@ http_version
1112
1085
The HTTP version to use, typically ``'1.1' `` or ``'2.0' ``. Leave it to ``null ``
1113
1086
to let Symfony select the best version automatically.
1114
1087
1088
+ .. _reference-http-client-retry-jitter :
1089
+
1115
1090
jitter
1116
1091
......
1117
1092
@@ -1139,6 +1114,8 @@ local_pk
1139
1114
The path of a file that contains the `PEM formatted `_ private key of the
1140
1115
certificate defined in the ``local_cert `` option.
1141
1116
1117
+ .. _reference-http-client-retry-max-delay :
1118
+
1142
1119
max_delay
1143
1120
.........
1144
1121
@@ -1173,6 +1150,8 @@ max_redirects
1173
1150
The maximum number of redirects to follow. Use ``0 `` to not follow any
1174
1151
redirection.
1175
1152
1153
+ .. _reference-http-client-retry-max-retries :
1154
+
1176
1155
max_retries
1177
1156
...........
1178
1157
@@ -1181,6 +1160,8 @@ max_retries
1181
1160
The maximum number of retries for failing requests. When the maximum is reached,
1182
1161
the client returns the last received response.
1183
1162
1163
+ .. _reference-http-client-retry-multiplier :
1164
+
1184
1165
multiplier
1185
1166
..........
1186
1167
@@ -1248,6 +1229,54 @@ client and to make your tests easier.
1248
1229
The value of this option is an associative array of ``domain => IP address ``
1249
1230
(e.g ``['symfony.com' => '46.137.106.254', ...] ``).
1250
1231
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
+
1251
1280
retry_strategy
1252
1281
..............
1253
1282
0 commit comments