file_get_contents via HTTP on same website gets timeout
3 posts
• Page 1 of 1
file_get_contents via HTTP on same website gets timeout
Precondition:
Two files:
- File "index.php"
- File "test.php"
"index.php" contains:
"test.php" contains:
With "localhost:43517" being the URL of the current project in Visual Studio.
Steps/error:
When calling "http://localhost:43517/index.php" in the browser, the page loads for approx. 60 seconds and then only "Hello World" is printed.
Expected results:
I would expect to immediately get a page in my browser printing "Hello World", followed by "Test".
More information:
- When calling e.g. "http://stackoverflow.com" instead of my localhost URL, everything works as expected.
- When using the above two files on a live Apache webserver, the expected result is correctly displayed.
Question:
Can you comment on whether this is kind of limitation of your used web server?
(e.g. like single-threading or something like this?)
Is there a fix or workaround?
Two files:
- File "index.php"
- File "test.php"
"index.php" contains:
- Code: Select all
<?php
echo "Hello World!";
$c = file_get_contents("http://localhost:43517/test.php");
echo $c;
?>
"test.php" contains:
- Code: Select all
<?php
echo "Test";
?>
With "localhost:43517" being the URL of the current project in Visual Studio.
Steps/error:
When calling "http://localhost:43517/index.php" in the browser, the page loads for approx. 60 seconds and then only "Hello World" is printed.
Expected results:
I would expect to immediately get a page in my browser printing "Hello World", followed by "Test".
More information:
- When calling e.g. "http://stackoverflow.com" instead of my localhost URL, everything works as expected.
- When using the above two files on a live Apache webserver, the expected result is correctly displayed.
Question:
Can you comment on whether this is kind of limitation of your used web server?
(e.g. like single-threading or something like this?)
Is there a fix or workaround?
- uwe
- Posts: 21
- Joined: October 10th, 2016, 8:39 am
Re: file_get_contents via HTTP on same website gets timeout
This seems to be related due to the fact that the built-in PHP web server is single threaded.
See this similar posting.
See this similar posting.
- uwe
- Posts: 21
- Joined: October 10th, 2016, 8:39 am
Re: file_get_contents via HTTP on same website gets timeout
Hello,
Thanks for the post with scenario.
Yes, that's exactly the issue. PHP Build-in server can handle only one request at a time. You can easily overcome this by moving to other web server, e.g. IIS Express ( which we do have build-in support for), or XAMPP or other Apache distribution.
Thanks!
Thanks for the post with scenario.
Yes, that's exactly the issue. PHP Build-in server can handle only one request at a time. You can easily overcome this by moving to other web server, e.g. IIS Express ( which we do have build-in support for), or XAMPP or other Apache distribution.
Thanks!
Miloslav Beno │ DEVSENSE s.r.o. │ @miloslavbeno │ miloslav@devsense.com
-
Miloslav Beno - Posts: 1252
- Joined: January 7th, 2012, 8:36 pm
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 45 guests