After 120 seconds i always get "file-get-contents(http://.... ) failed to open stream: HTTP request failed!" when i use "file_get_contents".
Even with
- Code: Select all
file_get_contents($url, 0, stream_context_create(array('http' => array('timeout' => 600))))
I've change the php.ini to "default_socket_timeout = 600" - still after 120 seconds: Timeout.
Next i've used cURL to make a new funktion:
- Code: Select all
public static function file_get_contents_curl($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, -1);
curl_setopt($ch, CURLOPT_TIMEOUT, 600);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
And guess what - timout after 120 seconds.
I'll guess it is either apache or ubtunu that messes everything up, because using cURL ends php scrip after 120 seconds, but no longer with an HTTP timout. It just stops the URL request and continues with the rest of the code.