Curl error: Operation timed out

前端 未结 2 1853
粉色の甜心
粉色の甜心 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:04

    Some time this error in Joomla appear because some thing incorrect with SESSION or coockie. That may because incorrect HTTPd server setting or because some before CURL or Server http requests

    so PHP code like:

      curl_setopt($ch, CURLOPT_URL, $url_page);
      curl_setopt($ch, CURLOPT_HEADER, 1);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
      curl_setopt($ch, CURLOPT_TIMEOUT, 30); 
      curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
      curl_setopt($ch, CURLOPT_REFERER, $url_page);
      curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
      curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__) . "./cookie.txt");
      curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . "./cookie.txt");
      curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id());
    
      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
      if( $sc != "" ) curl_setopt($ch, CURLOPT_COOKIE, $sc);
    

    will need replace to PHP code

      curl_setopt($ch, CURLOPT_URL, $url_page);
      curl_setopt($ch, CURLOPT_HEADER, 1);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
      curl_setopt($ch, CURLOPT_TIMEOUT, 30); 
    //curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
      curl_setopt($ch, CURLOPT_REFERER, $url_page);
      curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
    //curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__) . "./cookie.txt");
    //curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . "./cookie.txt");
    //curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id());
    
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); // !!!!!!!!!!!!!
      //if( $sc != "" ) curl_setopt($ch, CURLOPT_COOKIE, $sc);
    

    May be some body reply how this options connected with "Curl error: Operation timed out after .."

提交回复
热议问题