@@ -34,6 +34,8 @@ trait MakeHttpRequests
3434
3535 private $ mustache = null ;
3636
37+ private $ timeout = 0 ;
38+
3739 private function getMustache ()
3840 {
3941 if ($ this ->mustache === null ) {
@@ -98,6 +100,23 @@ private function prepareRequest(array &$data, array &$config)
98100 return $ request ;
99101 }
100102
103+ /**
104+ * Set timeout from endpoint config or from BPMN errorHandling
105+ *
106+ * @param array $endpoint
107+ * @param array $config
108+ *
109+ * @return void
110+ */
111+ private function setTimeout (array $ endpoint , array $ config )
112+ {
113+ $ this ->timeout = (int ) Arr::get ($ endpoint , 'timeout ' , 0 );
114+ $ bpmnTimeout = Arr::get ($ config , 'errorHandling.timeout ' , null );
115+ if ($ bpmnTimeout ) {
116+ $ this ->timeout = (int ) $ bpmnTimeout ;
117+ }
118+ }
119+
101120 /**
102121 * Prepare data to be used in body (mustache)
103122 *
@@ -202,6 +221,8 @@ private function prepareRequestWithOutboundConfig(array $requestData, array &$co
202221 $ request = [$ method , $ url , $ headers , $ body , $ bodyType ];
203222 $ request = $ this ->addAuthorizationHeaders (...$ request );
204223
224+ $ this ->setTimeout ($ endpoint , $ config );
225+
205226 return $ request ;
206227 }
207228
@@ -427,7 +448,13 @@ private function responseWithHeaderData($response, array $data = [], array $conf
427448 */
428449 private function call ($ method , $ url , array $ headers , $ body , $ bodyType )
429450 {
430- $ client = $ this ->client ?? new Client (['verify ' => $ this ->verifySsl ]);
451+ $ client = $ this ->client ?? app ()->make (Client::class, [
452+ 'config ' => [
453+ 'verify ' => $ this ->verifySsl ,
454+ 'timeout ' => $ this ->timeout ,
455+ ],
456+ ]);
457+
431458 $ options = [];
432459 if ($ bodyType === 'form-data ' ) {
433460 $ options ['form_params ' ] = json_decode ($ body , true );
0 commit comments