A little while ago I noticed some Soap errors emitting from my app and I started to investigate them. Stuff like:
SoapClient::SoapClient(http://###.###.###.###:8080/path/to/some.wsdl): failed to open stream: HTTP request failed!SoapClient::SoapClient(): I/O warning : failed to load external entity "http://###.###.###.###:8080/path/to/some.wsdl"SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://###.###.###.###:8080/path/to/some.wsdl' : failed to load external entity "http://###.###.###.###:8080/path/to/some.wsdl"
It looked like a timeout on the remote server (WSDL caching was turned off). After bouncing that server and having no luck, I tried to just file_get-contents() the WSDL to see what would happen…
No dice: After about 20 seconds or so I got the same stream error:
file_get_contents(http://###.###.###.###:8080/path/to/some.wsdl) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed!
In a last ditch effort, I tried to read the contents via the curl_* functions, and I do in fact get what I’m looking for.
… tl;dr?
- SoapClient and file_get_contents appear to be timing out (though not an explicit “Failed to open stream, connection timed out”)
- It appears to be related to streams since curl gives me what I’m looking for.
- I’ve got a lot of code that depends on
SoapClientandfile_get_contentsso switching to an all curl solution isn’t really an option. - This is not a DNS issue as I can resolve external names fine (and my target resource is an IP)
allow_url_fopenis enabled.
Any ideas?
allow_url_fopenneeds to beOnin your PHP settings forfile_get_contentsto work with URLs. It’ll give you that exact error otherwise. Double-check your PHP settings by loading a page with aphpinfo();call to make sure they’re not being overridden by a different php.ini or .htaccess file.I’d guess a firewall problem otherwise but you say curl works from inside PHP, which would be opening sockets in the same manner.