PHP has these two options related to timeout: CURLOPT_CONNECTTIMEOUT
and CURLOPT_TIMEOUT
.
The descriptions on the PHP site are a bit vague. What's the difference?
To use a real world example: say you're sending GET vars to a URL via cURL and you want to receive a XML back, would CURLOPT_CONNECTTIMEOUT
relate to the maximum amount of time it can take to connect to the server and CURLOPT_TIMEOUT
the maximum amount of time it can take to send the XML back?
CURLOPT_TIMEOUT. The maximum number of seconds to allow cURL functions to execute. CURLOPT_TIMEOUT_MS. The maximum number of milliseconds to allow cURL functions to execute.
CURLOPT_CONNECTTIMEOUT is the maximum amount of time in seconds that is allowed to make the connection to the server. It can be set to 0 to disable this limit, but this is inadvisable in a production environment.
CURLOPT_CONNECTTIMEOUT is not a segment of the time represented by CURLOPT_TIMEOUT
If CURLOPT_CONNECTTIMEOUT is set to 3 seconds and CURLOPT_TIMEOUT to 4 seconds, execution may take up to 7 seconds.
I tested this by simulating slow server connecting (iptables drop).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With