File_get_contents 1 minute timeout for https?

I'm having difficulty with PHP hanging for 60 seconds while accessing certain resources via https. file_get_contents

I am not sure if this is a problem with the client or server.

On the client

Work with the command line:

$ URL="https://example.com/some/path"
$ wget "$URL" -O /dev/null -q # takes a few milliseconds
$ curl "$URL" >/dev/null      # takes a few milliseconds
$ php -r 'file_get_contents("'"$URL"'")' # takes 61s!

On server

The string is written to the Apache access log (2.4) for the correct SSL host immediately , with a response of 200 (success). This confuses the confusing timeline:

  • 0s php file_get_contents running on the client
  • Apache 0.2s access protocol for server completed successfully (200).
  • who knows what is going on here ???
  • Client 60.2s receives the file.

Ubuntu 14.04 Debian 8. Debian 8, Apache 2.4 ITK- PHP 5.6. ( ACCEPT ), . IPv6, , , , - IPv6. , , AAAA, apache , (a) SSL Ok (b) .

+4
3

: , 60,2 ? , file_get_contents() , , , . , HTTP-, , .

- ?

$context = stream_context_create(['http' => ['header' => 'Connection: close\r\n']]);
file_get_contents("https://example.com/some/path", false, $context);

. , "https" ; .

+1

script php -r 'file_get_contents("'"$URL"'")' & script script pid. strace -p %pid%

+1

, !

, / ITK Apache MPM.

  • (file_get_contents, ) .

  • Without this module, the problem disappears.

This is not the first error I have found with this module since upgrading to Debian Jessie / Apache 2.4. I will try to report it.

Yeah! I was right. It was a bug , and a fix was released there, Debian jessie currently offers updates.

+1
source

Source: https://habr.com/ru/post/1620514/


All Articles