Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Guzzle difference between 'connect_timeout' and 'timeout'

Tags:

guzzle

What's the difference between 'connect_timeout' and 'timeout' request options in Guzzle.

like image 993
Tshwarelo Avatar asked Sep 16 '16 08:09

Tshwarelo


People also ask

What is the difference between connection timeout and connection request timeout?

request timeout — a time period required to process an HTTP call: from sending a request to receiving a response. connection timeout — a time period in which a client should establish a connection with a server.

How do I set timeout on guzzle?

If you have a queued job that uses Guzzle to make a request, make sure you set a timeout value for the guzzle request: (new \GuzzleHttp\Client())->get('http://domain.com', [ 'timeout' => 15 ]);


1 Answers

The most basic way I can explain this is (from what I understand):

  • connect_timeout - Time Guzzle will wait to establish a connection to the server
  • timeout - Time Guzzle will wait, once a connection has been made, for the server to handle the request. For example waiting on a long running script.

Also this answer relating to curl's timeouts is quite nice - https://unix.stackexchange.com/questions/94604/does-curl-have-a-timeout/94612

The flags that get used to define the timeouts, --connect-timeout and --max-time, make the difference a lot clearer.

I also believe the Guzzle options are linked to these curl options

  • timeout - https://curl.haxx.se/libcurl/c/CURLOPT_TIMEOUT.html
  • connect_timeout - https://curl.haxx.se/libcurl/c/CURLOPT_CONNECTTIMEOUT.html
like image 190
Carlton Avatar answered Sep 23 '22 12:09

Carlton