0

I am running Windows Server and it hosts my PHP files. I am using "file_get_contents()" to call another PHP script and return the results. (I have also tried cURL with the same result)

This works fine. However if I execute my script, then re execute it almost straight away, I get an error:

"Warning: file_get_contents(http://...x.php): failed to open stream: HTTP request failed!"

So this works fine if I leave a minute or two between calling this PHP file via the browser. But after a successful attempt, if I retry too quickly, then it fails. I have even changed the URL in the line "$html = file_get_contents($url, false, $context);" to an empty file that simply prints out a line, and the HTTP stream still doesn't open.

What could be preventing me to open a new HTTP stream? I suspect my server is blocking further outgoing streams but cannot find out where this would be configured in IIS.

Any help on this problem would be much appreciated.

**EDIT: ** In the script, I am calling a Java file that takes around 1.5 mins, and it is after this that I then call the PHP script that fails.

Also, when it fails, the page hangs for quite some time. During this time, if I open another connection to the initial PHP page then the previous page (still hanging) then completes. It seems like a connection timeout somewhere.

I have set the timeout appropriately in IIS Manager and in PHP

  • The same question you can use as a reference: [https://stackoverflow.com/questions/697472/php-file-get-contents-returns-failed-to-open-stream-http-request-failed](https://stackoverflow.com/questions/697472/php-file-get-contents-returns-failed-to-open-stream-http-request-failed). – samwu Feb 25 '22 at 07:09
  • Thanks Samwu, I had already seen that post, and it prompted me to try cURL, with no avail. I have edited my main question to include more context – InternetUser101 Feb 25 '22 at 08:31
  • It is difficult to reproduce your problem, I suggest you open a case via: https://support.microsoft.com. – samwu Feb 28 '22 at 10:10

0 Answers0