php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62890 Set default_socket_timeout to -1 causes not able to connect
Submitted: 2012-08-22 10:25 UTC Modified: -
Votes:6
Avg. Score:4.0 ± 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:
Status: Open Package: Sockets related
PHP Version: 5.3.16 OS: Mac Lion 10.7.4
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2012-08-22 10:25 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 04:01:26 2019 UTC