间歇性无法打开流(HTTP 请求)
我正在运行 Windows Server,它托管我的 PHP 文件。 我正在使用“file_get_contents()”调用另一个 PHP 脚本并返回结果。 (我也尝试过 cURL,结果相同)
这工作正常。但是,如果我执行我的脚本,然后几乎立即重新执行它,我会收到错误:
“警告:file_get_contents(http://...x.php):无法打开流:HTTP 请求失败!< /em>"
因此,如果我在通过浏览器调用此 PHP 文件之间留出一两分钟的时间,效果就很好。但在成功尝试后,如果我重试太快,就会失败。我什至更改了“$html = file_get_contents($url, false, $context);”行中的 URL到一个空文件,仅打印出一行,并且 HTTP 流仍然无法打开。
是什么阻止我打开新的 HTTP 流? 我怀疑我的服务器正在阻止进一步的传出流,但无法找出在 IIS 中进行配置的位置。
任何有关这个问题的帮助将不胜感激。
**编辑:** 在脚本中,我调用一个 Java 文件大约需要 1.5 分钟,在此之后我调用失败的 PHP 脚本。
此外,当失败时,页面会挂起相当长的时间。在此期间,如果我打开与初始 PHP 页面的另一个连接,则前一个页面(仍然挂起)就会完成。似乎某处连接超时。
我已经在 IIS 管理器和 PHP 中适当设置了超时
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论