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