Edit report at https://bugs.php.net/bug.php?id=43098&edit=1
ID: 43098
Comment by: sijanecantonluka at gmail dot com
Reported by: harvie at email dot cz
Summary: file_get_contents() freezes (probably caused by
fopen())
Status: No Feedback
Type: Bug
Package: HTTP related
Operating System: Linux (Debian Etch) - php5-cli
PHP Version: 5.2.4
Block user comment: N
Private report: N
New Comment:
I am facing the same bug under
Linux 5.2.0-2-amd64 #1 SMP Debian 5.2.9-2 (2019-08-21) x86_64 GNU/Linux
I am using php7.3.9 installed from my operating system repository (apt). My script hangs (cli) and
reaches max execution time (fpm) when I execute
file_get_contents("http://example.example/");
.
The thing is that local files can be accessed and, more importantly, localhost can be accessed
(accessed means it does not hang). But, because I use curl for Internet requests, I didn't
notice this, until (from 7.2), I upgraded to 7.3. I was unable to use composer, because it uses
file_get_contents. After a minute of querying it responded with a
failed to open stream: Connection timed out
.
This sounds like a non-php related bug, but simce curl works, I am questioning this...
Previous Comments:
------------------------------------------------------------------------
[2014-09-05 17:21:07] f dot eeprom at gmail dot com
It still happens. PHP 5.3.10 here.
I have a script that keeps polling data from an online API every 10 seconds. After some days or
normal function, it freezes at file_get_contents() even with the timeout parameter set to 10 in the
http options. It often happens after/during connection problems with the server.
protected function retrieveJSON($URL) {
$opts = array('http' =>
array(
'method' => 'GET',
'timeout' => 10,
)
);
$context = stream_context_create($opts);
$feed = file_get_contents($URL, false, $context); <--- FREEZE
$json = json_decode($feed, true);
return $json;
}
------------------------------------------------------------------------
[2013-02-18 00:33:53] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
------------------------------------------------------------------------
[2010-11-24 09:19:38] jani@php.net
Does it happen with PHP 5.3.3? I still can not reproduce it.
------------------------------------------------------------------------
[2010-03-02 21:49:13] dyekimov at uniplat dot ru
So, has anyone found a way out of this problem?
Is it a known bug?
------------------------------------------------------------------------
[2007-10-26 10:49:02] harvie at email dot cz
Yeah! Thats what i need... Something like default_poll_timeout setting...
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=43098
--
Edit this bug report at https://bugs.php.net/bug.php?id=43098&edit=1