Re: [SOAP] soapclient using https randomly closes connection
[email protected] (Bernhard Ege)
| Newsgroups | php.soap,php.soap |
|---|---|
| Message-ID | <[email protected]> |
Sriram Natarajan wrote: > > > Bernhard Ege wrote: >> I am using php 5.2.9 (solaris) and have access to a .NET webservice >> that I >> have to access using https. >> >> In most cases, accessing it works just fine, but every now and again, >> SoapClient closes the connection before actually having transfered the >> request, erroring with "could not connect to host ...". >> >> I have captured the actual communication using snoop and examined the >> result >> in wireshark and I see that the tcp connection to the webservice is >> established correct, but before the request is transmitted, SoapClient >> closes the tcp-connection which is acknowledged by the webservice >> which also >> resets the TCP connection. >> >> When I disable the caching of the WSDL file for SoapClient, I get these >> errors (not always, only sometimes): >> >> Warning: SoapClient::SoapClient() [soapclient.soapclient]: failed to >> create >> an SSL context in /space/hom >> >> Warning: SoapClient::SoapClient() [soapclient.soapclient]: Failed to >> enable >> crypto in /space/home >> > This warning suggests that PHP is unable to create a SSL stream context > . By default, if you disable caching, PHP has to download the wsdl to > your /tmp directory. Is is possible you are running out of disk space in > /tmp. > - Sriram Thank you for the response, but there is plenty of space to save the WSDL file. Also, if I cache the wsdl file, the actual service calls fail to send a request (the tcp connection is created). As the same soap service can be accessed via http instead of https, AND http never fails, the problem seems to be creating a SSL context for some reason. When retrying, it works after about 10-15 seconds but fails immediately when retrying before that. Because https is unrealiable, I have created a http<->https tunnel using stunnel and I have made SoapClient access using http via stunnel (that converts to/from https stream) to the webservice. Doing this is so far 100% reliable (even without caching the wsdl file). To me this clearly indicates that SoapClient has occasional problems with SSL (in php 5.2.9 on Solaris). I'll create en rc-file to ensure stunnel is started when the OS boots and with that I have worked around the bug in SoapClient. /Bernhard