Operation timed out after 10001 milliseconds with 0 bytes received

PHP Curl 请求接口时遇到下列错误!

{"error":"Operation timed out after 10001 milliseconds with 0 bytes received"}

 

{"error":"Empty reply from server"}

 

这两个问题,第一个问题大概意思是请求时间过长造成的。

解决办法:

// 超时设置

    curl_setopt($curl, CURLOPT_TIMEOUT300);

 

设置更大的时间

然鹅,造成整个问题的原因是:

$header = array(

                        'Content-Type: application/json',

                        'Content-Length: ' . strlen(json_encode($post_data))

                    );

 

Content-Length 对就是这个参数,造成的假死和timeout

参考链接: https://www.jianshu.com/p/ea12be063b2e

 

文章来源:刘俊涛的博客 欢迎关注公众号、留言、评论,一起学习。

__________________________________________________________________________________

若有帮助到您,欢迎点击推荐,您的支持是对我坚持最好的肯定(*^_^*)

耶和华是我的牧者,我必不至缺乏。
原文地址:https://www.cnblogs.com/lovebing/p/13591119.html