1

I'm using PHP's built-in SoapClient, and it needs to time out after 5 seconds. Therefore I'm using ini_set("default_socket_timeout", 5);. However, when fetching the WSDL it times out after 10 seconds instead. If I change the default socket timeout to i.e. 1 second it times out after 2 and so on. The actual soap calls time out after 5 seconds as expected though.

Is this a bug in PHP, expected behaviour or is there some additional setting I need to change? Using PHP 5.6.28.

Thanks!

1
  • Can you paste an example of your code, and does the same timeout behaviour happen if you use file_get_contents($wsdl)? Commented Jan 5, 2017 at 20:56

1 Answer 1

1

There is an additional timeout setting that you will want to change: connection_timeout which is passed to the SoapClient in the $options array parameter. This timeout controls how long the SoapClient waits (in seconds) to connect to the Soap service, which is what you are looking for.

Usage:

$soapclient = new SoapClient($uri, array('connection_timeout' => 5)); 

Once connected, "default_socket_timeout" comes into play and controls how long the SoapClient waits for a response.

Sign up to request clarification or add additional context in comments.

4 Comments

It sounds reasonable... However it still takes 10 seconds for it to time out with the 'connection_timeout' setting no matter what i set it to.
And default_socket_timeout is still set to 5? Strange indeed. Is the WSDL on http or https?
Yes. It's over http to localhost.
For me, it's reproducible only with HTTP but not with HTTPS.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.