I'm using the following method trying to set a timeout to the SoapClient. $this->_soap is a Zend_Soap_Client which wraps a SoapClient object.
Sometimes the API call I'm doing takes > 60 seconds. I'm trying to set a 10 seconds timeout but this doesn't work.
1. Using stream_context_create:
public function setTimeout($timeout) { $this->_soap->setStreamContext(stream_context_create(array( 'http' => array( 'timeout' => intval($timeout) ) ))); } 2. I tried as Part of the constructor, like in this answer (PHP SoapClient Timeout) which is working with SoapClient object:
$this->_soap = new \Zend_Soap_Client($this->_wsdl, array( 'soap_version' => SOAP_1_1, 'connection_timeout' => intval($timeout) )); But it is not working because Zend doesn't support this option and throws Unknown SOAP client option.
3. I tried default_socket_timeout:
ini_set("default_socket_timeout", intval($timeout)); None of those did work:
API calls times (seconds): min 0.3012 max 23.0334 avg 2.5005 What I could try now is, to append to the public function setOptions($options) in "\Zend\Soap\Client.php" with a timeout, but I don't want to touch the Zend core files..