To set a timeout for a Curl command, you can use the --connect-timeout parameter to set the maximum time in seconds that you allow Curl to connect to the server, or the --max-time (or -m) parameter for the total time in seconds that you authorize the whole operation.
Tell curl with -m / --max-time the maximum time, in seconds, that you allow the command line to spend before curl exits with a timeout error code (28). When the set time has elapsed, curl will exit no matter what is going on at that moment—including if it is transferring data. It really is the maximum time allowed.
CURLOPT_CONNECTTIMEOUT: Defaults to 300 seconds. CURLOPT_CONNECTTIMEOUT_MS: No default. CURLOPT_ACCEPTTIMEOUT_MS: Defaults to 60000 ms.
Use curl_errno()
Code 28 is timeout.
you can check error number and its' description like this:
// Check if any error occurred
if(curl_errno($ch))
{
echo 'Curl error: ' . curl_error($ch);
}
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