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

 

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

__________________________________________________________________________________

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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM