Bug #62890 [Opn]: Set default_socket_timeout to -1 causes not able to connect

From: Date: Tue, 09 Jun 2020 09:23:56 +0000
Subject: Bug #62890 [Opn]: Set default_socket_timeout to -1 causes not able to connect
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227368@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=62890&edit=1 ID: 62890 Updated by: cmb@php.net Reported by: fallingdust at gmail dot com Summary: Set default_socket_timeout to -1 causes not able to connect Status: Open Type: Bug Package: Sockets related Operating System: Mac Lion 10.7.4 -PHP Version: 5.3.16 +PHP Version: 7.3 Block user comment: N Private report: N New Comment: I can confirm that with default_socket_timeout=-1, file_get_contents('http://www.google.com') succeeds, but file_get_contents('https://www.google.com') fails. Apparently, some code paths ignore negative timeouts by special casing them[1], and others don't. [1] <https://github.com/php/php-src/blob/PHP-7.3/main/network.c#L1243> Previous Comments: ------------------------------------------------------------------------ [2018-07-01 18:04:46] jose dot nobile at gmail dot com It is reproducible on Linux (Centos 6.9/CloudLinux). I need set it to -1 because Redis:brpoplpush timeout each minute (The default socket timeout value is 60 secs), but file_get_contents fail with file_get_contents(): SSL: Handshake timed out, file_get_contents(): Failed to enable crypto, file_get_contents(https://someExampledomain.tld): failed to open stream: operation failed. I have to set ['http' => ['timeout' => 10]] via stream_context_create to make it works. Tested in PHP 7.2.7 ------------------------------------------------------------------------ [2016-04-26 16:52:56] pembo at neonerve dot com This appears to only be an issue on Macs. When using it on Windows / Linux it performs as expected. ------------------------------------------------------------------------ [2012-08-22 10:25:06] fallingdust at gmail dot com Description: ------------ --- From manual page: http://www.php.net/filesystem.configuration --- php.ini configuration: allow_url_fopen = On allow_url_include = Off ;from="john@doe.com" ;user_agent="PHP" default_socket_timeout = 60 ;auto_detect_line_endings = Off Test script: --------------- php -r 'ini_set("default_socket_timeout", -1); echo file_get_contents("http://www.google.com");' Expected result: ---------------- print the html of google page. Actual result: -------------- PHP Warning: file_get_contents(http://www.google.com): failed to open stream: Operation now in progress in Command line code on line 1 PHP Stack trace: PHP 1. {main}() Command line code:0 PHP 2. file_get_contents() Command line code:1 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=62890&edit=1

« previous php.bugs (#227368) next »