|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62890 default_socket_timeout=-1 causes connection to timeout
Submitted: 2012-08-22 10:25 UTC Modified: 2020-06-09 10:46 UTC
Avg. Score:3.9 ± 1.5
Reproduced:5 of 5 (100.0%)
Same Version:2 (40.0%)
Same OS:2 (40.0%)
From: fallingdust at gmail dot com Assigned: cmb (profile)
Status: Closed Package: OpenSSL related
PHP Version: 7.3 OS: Mac Lion 10.7.4
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
24 - 6 = ?
Subscribe to this entry?

 [2012-08-22 10:25 UTC] fallingdust at gmail dot com
From manual page:

php.ini configuration:

allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60
;auto_detect_line_endings = Off

Test script:
php -r 'ini_set("default_socket_timeout", -1); echo file_get_contents("");'

Expected result:
print the html of google page.

Actual result:
PHP Warning:  file_get_contents( 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


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-04-26 16:52 UTC] pembo at neonerve dot com
This appears to only be an issue on Macs. When using it on Windows / Linux it performs as expected.
 [2018-07-01 18:04 UTC] 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
 [2020-06-09 09:23 UTC]
-PHP Version: 5.3.16 +PHP Version: 7.3
 [2020-06-09 09:23 UTC]
I can confirm that with default_socket_timeout=-1,
file_get_contents('') succeeds, but
file_get_contents('') fails.

Apparently, some code paths ignore negative timeouts by special
casing them[1], and others don't.

[1] <>
 [2020-06-09 10:38 UTC]
-Summary: Set default_socket_timeout to -1 causes not able to connect +Summary: default_socket_timeout=-1 causes connection to timeout -Package: Sockets related +Package: OpenSSL related
 [2020-06-09 10:46 UTC]
-Assigned To: +Assigned To: cmb
 [2020-06-09 11:38 UTC]
The following pull request has been associated:

Patch Name: Fix #62890: default_socket_timeout=-1 causes connection to timeout
On GitHub:
 [2020-06-09 14:49 UTC]
Automatic comment on behalf of
Log: Fix #62890: default_socket_timeout=-1 causes connection to timeout
 [2020-06-09 14:49 UTC]
-Status: Assigned +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jun 25 18:01:32 2024 UTC