Andrew
Andrew

Reputation: 470

Preventing Curl From Timing Out when transferring a large file

I have a 25 second timeout on my PHP Curl Opts. If it goes over that I get the error:

Operation timed out after 25000 milliseconds with 0 bytes received

Sometimes though I get an error that makes it seem like it's timing out while it's downloading the file like so.

Operation timed out after 25000 milliseconds with 196879 bytes received

Is there a way to make Curl extend the timeout if it's downloading data? Or am I reading this wrong and it has waited 25 seconds since receiving the last data?

The settings are as follows:

curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,3); 
curl_setopt($ch, CURLOPT_TIMEOUT, 25); 

Thanks

Upvotes: 1

Views: 2107

Answers (1)

Ian Thompson
Ian Thompson

Reputation: 187

Set the curl timeouts to 0 to avoid timing out all together

curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,0); 
curl_setopt($ch, CURLOPT_TIMEOUT,0);

Upvotes: 1

Related Questions