Curl error: Operation timed out

前端 未结 2 1910
粉色の甜心
粉色の甜心 2021-02-12 18:43

I have the following fatal error when trying to use Curl:

PHP Fatal error:  Uncaught HTTP_Request2_MessageException: 
Curl error: Operation timed out after 30000         


        
2条回答
  •  暖寄归人
    2021-02-12 19:12

    Your curl gets timed out. Probably the url you are trying that requires more that 30 seconds.

    If you are running the script through browser, then set the set_time_limit to zero for infinite seconds.

    set_time_limit(0);
    

    Increase the curl's operation time limit using this option CURLOPT_TIMEOUT

    curl_setopt($ch, CURLOPT_TIMEOUT,500); // 500 seconds
    

    It can also happen for infinite redirection from the server. To halt this try to run the script with follow location disabled.

    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
    

提交回复
热议问题