Enigma: Socket Timeout always after 120 seconds

Alles, was den Apache betrifft, kann hier besprochen werden.

Enigma: Socket Timeout always after 120 seconds

Postby schismatic » 28. September 2017 16:57

I'm currently requesting a nodejs server (with php7.0 + apache2 + ubuntu 16.04) which does some heavy calculation and gives a response after about 5 minutes.

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))))
ends after 120 seconds.

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.
schismatic
 
Posts: 4
Joined: 06. September 2009 08:10

Re: Enigma: Socket Timeout always after 120 seconds

Postby Nobbie » 28. September 2017 19:47

schismatic wrote:I'll guess it is either apache or ubtunu that messes everything up,


Yes.

And where are you here? In the german forum of Xampp. Anyway, there is also a PHP timeout defined with max_execution_time. Maybe that is responsible for the timeout in your case.
Nobbie
 
Posts: 9807
Joined: 09. March 2008 13:04

Re: Enigma: Socket Timeout always after 120 seconds

Postby schismatic » 29. September 2017 07:10

Huch, das habe ich total übersehen das es heir ein deutsches Board ist. max_execution_time is ebenfalls bereits auf 0 eingesellt.
schismatic
 
Posts: 4
Joined: 06. September 2009 08:10

Re: Enigma: Socket Timeout always after 120 seconds

Postby Nobbie » 29. September 2017 10:54

Vielleicht kann die Remote Seite (welche?) nicht geöffnet werden oder hat seinerseits einen Timeout auf 120 Sekunden? Oder vielleicht hängt eine Firewall dazwischen, ggf. auch eine Firewall auf dem eigenen Ubuntu?
Nobbie
 
Posts: 9807
Joined: 09. March 2008 13:04


Return to Apache

Who is online

Users browsing this forum: No registered users and 5 guests