@@ -887,41 +887,6 @@ If you use for example
887
887
as the type and name of an argument, autowiring will inject the ``my_api.client ``
888
888
service into your autowired classes.
889
889
890
- .. _reference-http-client-retry-failed :
891
-
892
- By enabling the optional ``retry_failed `` configuration, the HTTP client service
893
- will automatically retry failed HTTP requests.
894
-
895
- .. code-block :: yaml
896
-
897
- # config/packages/framework.yaml
898
- framework :
899
- # ...
900
- http_client :
901
- # ...
902
- default_options :
903
- retry_failed :
904
- # retry_strategy: app.custom_strategy
905
- http_codes :
906
- 0 : ['GET', 'HEAD'] # retry network errors if request method is GET or HEAD
907
- 429 : true # retry all responses with 429 status code
908
- 500 : ['GET', 'HEAD']
909
- max_retries : 2
910
- delay : 1000
911
- multiplier : 3
912
- max_delay : 5000
913
- jitter : 0.3
914
-
915
- scoped_clients :
916
- my_api.client :
917
- # ...
918
- retry_failed :
919
- max_retries : 4
920
-
921
- .. versionadded :: 5.2
922
-
923
- The ``retry_failed `` option was introduced in Symfony 5.2.
924
-
925
890
auth_basic
926
891
..........
927
892
@@ -1024,6 +989,8 @@ ciphers
1024
989
A list of the names of the ciphers allowed for the SSL/TLS connections. They
1025
990
can be separated by colons, commas or spaces (e.g. ``'RC4-SHA:TLS13-AES-128-GCM-SHA256' ``).
1026
991
992
+ .. _reference-http-client-retry-delay :
993
+
1027
994
delay
1028
995
.....
1029
996
@@ -1055,6 +1022,8 @@ headers
1055
1022
An associative array of the HTTP headers added before making the request. This
1056
1023
value must use the format ``['header-name' => 'value0, value1, ...'] ``.
1057
1024
1025
+ .. _reference-http-client-retry-http-codes :
1026
+
1058
1027
http_codes
1059
1028
..........
1060
1029
@@ -1074,6 +1043,8 @@ http_version
1074
1043
The HTTP version to use, typically ``'1.1' `` or ``'2.0' ``. Leave it to ``null ``
1075
1044
to let Symfony select the best version automatically.
1076
1045
1046
+ .. _reference-http-client-retry-jitter :
1047
+
1077
1048
jitter
1078
1049
......
1079
1050
@@ -1105,6 +1076,8 @@ local_pk
1105
1076
The path of a file that contains the `PEM formatted `_ private key of the
1106
1077
certificate defined in the ``local_cert `` option.
1107
1078
1079
+ .. _reference-http-client-retry-max-delay :
1080
+
1108
1081
max_delay
1109
1082
.........
1110
1083
@@ -1143,6 +1116,8 @@ max_redirects
1143
1116
The maximum number of redirects to follow. Use ``0 `` to not follow any
1144
1117
redirection.
1145
1118
1119
+ .. _reference-http-client-retry-max-retries :
1120
+
1146
1121
max_retries
1147
1122
...........
1148
1123
@@ -1155,6 +1130,8 @@ max_retries
1155
1130
The maximum number of retries for failing requests. When the maximum is reached,
1156
1131
the client returns the last received response.
1157
1132
1133
+ .. _reference-http-client-retry-multiplier :
1134
+
1158
1135
multiplier
1159
1136
..........
1160
1137
@@ -1226,6 +1203,54 @@ client and to make your tests easier.
1226
1203
The value of this option is an associative array of ``domain => IP address ``
1227
1204
(e.g ``['symfony.com' => '46.137.106.254', ...] ``).
1228
1205
1206
+ .. _reference-http-client-retry-failed :
1207
+
1208
+ retry_failed
1209
+ ............
1210
+
1211
+ **type **: ``array ``
1212
+
1213
+ .. versionadded :: 5.2
1214
+
1215
+ The ``retry_failed `` option was introduced in Symfony 5.2.
1216
+
1217
+ This option configures the behavior of the HTTP client when some request fails,
1218
+ including which types of requests to retry and how many times. The behavior is
1219
+ defined with the following options:
1220
+
1221
+ * :ref: `delay <reference-http-client-retry-delay >`
1222
+ * :ref: `http_codes <reference-http-client-retry-http-codes >`
1223
+ * :ref: `jitter <reference-http-client-retry-jitter >`
1224
+ * :ref: `max_delay <reference-http-client-retry-max-delay >`
1225
+ * :ref: `max_retries <reference-http-client-retry-max-retries >`
1226
+ * :ref: `multiplier <reference-http-client-retry-multiplier >`
1227
+
1228
+ .. code-block :: yaml
1229
+
1230
+ # config/packages/framework.yaml
1231
+ framework :
1232
+ # ...
1233
+ http_client :
1234
+ # ...
1235
+ default_options :
1236
+ retry_failed :
1237
+ # retry_strategy: app.custom_strategy
1238
+ http_codes :
1239
+ 0 : ['GET', 'HEAD'] # retry network errors if request method is GET or HEAD
1240
+ 429 : true # retry all responses with 429 status code
1241
+ 500 : ['GET', 'HEAD']
1242
+ max_retries : 2
1243
+ delay : 1000
1244
+ multiplier : 3
1245
+ max_delay : 5000
1246
+ jitter : 0.3
1247
+
1248
+ scoped_clients :
1249
+ my_api.client :
1250
+ # ...
1251
+ retry_failed :
1252
+ max_retries : 4
1253
+
1229
1254
retry_strategy
1230
1255
..............
1231
1256
0 commit comments