Zend Soap Client timeout

Zend Framework, php

I’m working with a web service that’s showing to be slow at times. The default timeout in PHP is 30 seconds currently, so waiting around for it to timeout kinda sucks.

I decided to set the timeout to 10 seconds, to my surprise the timeout code is completely commented out in the class.

However they do provide a setStreamContext(), so I set http to timeout after 10 seconds like so:

$context = stream_context_create(array('http' => array('timeout' => 10)));
$soapClient->setStreamContext($context);

When the service slowed down to 15 second wait times, it died out early like it should have. I’m catching the exception, which isn’t pretty. Wish I knew when it was timing out, so I could log that specific case.

No Comments

Leave a Reply

Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>