In my code I have an include statement, that loads code from an external URL, which looks like this:
include 'http://123.123.123.123:8080/servlet/statemodel'
The issue is, that the servlet needs about 35 seconds to load.
If I access http://123.123.123.123:8080/servlet/statemodel in my browser, everything works fine (I modified the IP since it is not accessible via internet anyways).
Using the iclude statement however PHP tries about 20 seconds to include the file and then just continues with the code after the include statement.
There is no error message. Also using require brings no error message.
Is there a timeout for include? And why is there no error message?
Maybe tomcat actually sends data (http-header), but PHP waits only for about 20 sec for some content to follow?
Do I have an option to change this timeout?
You set the timeout with this:
ini_set("default_socket_timeout", $value);
But the default value is 60 seconds, which should be more than enough.
Maybe you can find more with:
error_reporting(E_ALL);
ini_set("display_errors", 1);
IMO the cleanest solution would be to load the content of the servlet with an AJAX request after serving the HTML of your PHP script. That way the user gets a quick result and you can show him that more content is being loaded.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With