PHP curl_exec () hangs

I am using this function to make cURL requests:

function curl_request($options) //single custom cURL request.
{
    $ch = curl_init();

    $options[CURLOPT_FOLLOWLOCATION] = true;
    $options[CURLOPT_COOKIEJAR] = 'cookies.txt';
    $options[CURLOPT_COOKIEFILE] = 'cookies.txt';
    $options[CURLINFO_HEADER_OUT] = true; 
    $options[CURLOPT_VERBOSE] = true;
    $options[CURLOPT_RETURNTRANSFER] = true;
    $options[CURLOPT_CONNECTTIMEOUT] = 5;
    $options[CURLOPT_TIMEOUT] = 5;

    curl_setopt_array($ch, $options);

    $response = curl_exec($ch);

    curl_close($ch);

    return $response;
}

      

The script hangs sometimes, but not always, at a line $response = curl_exec($ch)

. This happens even when the PHP script is installed with an infinite timeout (on the client side, Firebug treats this as "Aborted"). There is nothing in the error log. He just doesn't pass this line when it is hanging.

What could be? Any suggestions?

+1


source to share


1 answer


It seems that the problem is with server resources. When I switched to a better web host with higher bandwidth, everything worked fine.



+2


source







All Articles