防止 curl 在传输大文件时超时


Preventing Curl From Timing Out when transferring a large file

我的 PHP Curl Opts 有 25 秒的超时。 如果超过,我会收到错误:

Operation timed out after 25000 milliseconds with 0 bytes received

有时,尽管我会收到一个错误,使其在下载文件时看起来像超时。

Operation timed out after 25000 milliseconds with 196879 bytes received

有没有办法让 Curl 在下载数据时延长超时时间? 还是我读错了,自收到最后一个数据以来已经等待了 25 秒?

设置如下:

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

谢谢

将 curl 超时设置为 0 以避免全部超时

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