Search code examples
phpsslsoapsoap-client

PHP SoapClient::SoapClient failing with: SSL: Handshake timed and Failed to enable crypto


All of the following is running in Amazon EC2

I've been using ExactTarget's API to send emails for a few months now, and it just stopped working in my QA environment. All of the following code works properly in my production environment. Their SDK provides a class called ET_Client that extends the built in PHP SoapClient. The offending line of code is a call to

parent::__construct($wsdl, array('trace'=>1, 'exceptions'=>0,'connection_timeout'=>120)

Which is just a call to the SoapClient constructor.

The errors that I'm getting in my log files are as follows:

[26-Jul-2017 13:42:52 America/New_York] PHP Warning: SoapClient::SoapClient(): SSL: Handshake timed out in /var/www/vhosts/qa.devepc.com/repo/httpdocs/lib/vendor/exacttarget/fuel-sdk-php/ET_Client.php on line 74 [26-Jul-2017 13:42:52 America/New_York] PHP Warning: SoapClient::SoapClient(): Failed to enable crypto in /var/www/vhosts/qa.devepc.com/repo/httpdocs/lib/vendor/exacttarget/fuel-sdk-php/ET_Client.php on line 74 [26-Jul-2017 13:42:52 America/New_York] PHP Warning: SoapClient::SoapClient(https://webservice.exacttarget.com/ETFrameworkFault.xsd): failed to open stream: operation failed in /var/www/vhosts/qa.devepc.com/repo/httpdocs/lib/vendor/exacttarget/fuel-sdk-php/ET_Client.php on line 74 [26-Jul-2017 13:42:52 America/New_York] PHP Warning: SoapClient::SoapClient(): I/O warning : failed to load external entity "https://webservice.exacttarget.com/ETFrameworkFault.xsd" in /var/www/vhosts/qa.devepc.com/repo/httpdocs/lib/vendor/exacttarget/fuel-sdk-php/ET_Client.php on line 74 [26-Jul-2017 13:42:52 America/New_York] PHP Fatal error: SOAP-ERROR: Parsing Schema: can't import schema from 'https://webservice.exacttarget.com/ETFrameworkFault.xsd' in /var/www/vhosts/qa.devepc.com/repo/httpdocs/lib/vendor/exacttarget/fuel-sdk-php/ET_Client.php on line 74

I also discovered that I get the similar errors when trying to use file_get_contents() with an SSL resource.

This command:

php -r "var_dump(file_get_contents('https://google.com/'));"

gives me the following.

[26-Jul-2017 18:06:13 UTC] PHP Warning: file_get_contents(): SSL: Handshake timed out in Command line code on line 1 [26-Jul-2017 18:06:13 UTC] PHP Warning: file_get_contents(): Failed to enable crypto in Command line code on line 1 [26-Jul-2017 18:06:13 UTC] PHP Warning: file_get_contents(https://google.com/): failed to open stream: operation failed in Command line code on line 1

It's possible that the problem is due to subtle version differences between the two servers, however, it was working until 7/13/17, and there were no updates to the server since February. Also, I updated the entire server yesterday, and PHP went from 5.6.25 to 5.6.30. My production server is at 5.6.22.

I have tried to remedy the problem by manipulating the SSL stream using options passed to stream_context_create, but the errors persist.

When I've searched for "Failed to enable crypto" and "SSL: Handshake timed out" I find lots of results for using curl with a stream context, but haven't found anything that pertains to SoapClient. Additionally, I'd prefer not to edit the code in the ExactTarget Fuel SDK, because I want to leave vendor libraries unsullied.

Has anyone run into this or similar problems with soap, and if so, is there a solution?

Thanks in advance.


Solution

  • php.ini

    default_socket_timeout=-1  
    

    can cause this error. Try setting it to something other then -1