I am trying to force PHP to NEVER try to connect and send information to a webservice over a set period of time. I am using below and for some reason it will run over the time allowed and I can't figure out why. For example if I set it to 30 seconds, I will see that it takes a lot longer in some cases. I need to figure out a way to 100% kill connection if it takes too long.
TIA, Will
$intTimeout = $this->getTimeout(); $client = new SoapClient("{$this->url}?WSDL", array('trace' => 0, 'connection_timeout'=>$intTimeout)); try { $this->response = $client->someService($objPerson); } catch(Exception $e) { } $this->restoreTimeout();
function getTimeout() { $intTimeout = @$this->timeout ? $this->timeout : 60; $_SESSION['old_sock'] = ini_get('default_socket_timeout'); ini_set('default_socket_timeout', $intTimeout); return $intTimeout; } function restoreTimeout() { $intCurSockTime = @$_SESSION['old_sock']; if($intCurSockTime) ini_set('default_socket_timeout', $intCurSockTime); }