@@ -137,11 +137,34 @@ Configuration
137
137
* `proxy `_
138
138
* `query `_
139
139
* `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
+
140
152
* `timeout `_
141
153
* `max_duration `_
142
154
* `verify_host `_
143
155
* `verify_peer `_
144
156
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
+
145
168
* `http_method_override `_
146
169
* `ide `_
147
170
* :ref: `lock <reference-lock >`
@@ -742,6 +765,33 @@ If you use for example
742
765
as the type and name of an argument, autowiring will inject the ``my_api.client ``
743
766
service into your autowired classes.
744
767
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
+
745
795
auth_basic
746
796
..........
747
797
@@ -769,6 +819,19 @@ in the `Microsoft NTLM authentication protocol`_. The value of this option must
769
819
follow the format ``username:password ``. This authentication mechanism requires
770
820
using the cURL-based transport.
771
821
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
+
772
835
base_uri
773
836
........
774
837
@@ -837,6 +900,36 @@ ciphers
837
900
A list of the names of the ciphers allowed for the SSL/TLS connections. They
838
901
can be separated by colons, commas or spaces (e.g. ``'RC4-SHA:TLS13-AES-128-GCM-SHA256' ``).
839
902
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
+
840
933
headers
841
934
.......
842
935
@@ -845,6 +938,14 @@ headers
845
938
An associative array of the HTTP headers added before making the request. This
846
939
value must use the format ``['header-name' => header-value, ...] ``.
847
940
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
+
848
949
http_version
849
950
............
850
951
@@ -870,6 +971,15 @@ local_pk
870
971
The path of a file that contains the `PEM formatted `_ private key of the
871
972
certificate defined in the ``local_cert `` option.
872
973
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
+
873
983
max_duration
874
984
............
875
985
@@ -896,6 +1006,22 @@ max_redirects
896
1006
The maximum number of redirects to follow. Use ``0 `` to not follow any
897
1007
redirection.
898
1008
1009
+ max_retry
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
+
899
1025
no_proxy
900
1026
........
901
1027
0 commit comments