Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
等待CURL请求响应的最长时间-php_Php_Curl - Fatal编程技术网

等待CURL请求响应的最长时间-php

等待CURL请求响应的最长时间-php,php,curl,Php,Curl,我正在对一个api执行一个Curl请求,该api定期超时,并出现504错误。 主要问题是504需要60秒才能响应。我想在转移到其他进程之前设置一个最长等待时间,这样504就不会降低其他进程的速度,有人知道如何使用php和Curl实现这一点吗?我在Curl选项设置中尝试了以下与时间相关的选项(上2个): // Set curl options curl_setopt($ch, CURLOPT_HTTPHEADER, $headr); curl_setopt($ch,

我正在对一个api执行一个Curl请求,该api定期超时,并出现504错误。 主要问题是504需要60秒才能响应。我想在转移到其他进程之前设置一个最长等待时间,这样504就不会降低其他进程的速度,有人知道如何使用php和Curl实现这一点吗?我在Curl选项设置中尝试了以下与时间相关的选项(上2个):

// Set curl options
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headr);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_VERBOSE, true);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_HEADER, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// Set curl time options
        curl_setopt($curl, CURLOPT_TIMEOUT_MS, 2000); //in miliseconds
        curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, 500); //in miliseconds
然而,超时和连接超时似乎并不起作用。还有其他人有什么建议吗

谢谢


Matt

PHP使用什么版本的curl?检查
phpinfo()
并查看它报告的curl版本
CURL\u VERSION\u IPV6
不是CURL版本。它只是表示您的版本支持IPV6策略,版本为7.38.0apokryfos,是否有任何原因需要重新设置版本号?7.16之前的版本不支持
CURLOPT\u TIMEOUT\u MS