php soap error fetching http headers
Asked Answered
P

1

6

I am working on a PHP script that's processing a lot of data through a SOAP connection. Estimates of the total run time of the script look to be several days if it doesn't encounter any errors. The problem I'm running into is the script will run for a while, anywhere from an hour to a day, and then the SOAP connection will die with the error "error fetching http headers".

I've seen many articles suggesting increasing the default_socket_timeout setting and I've tried this. It hasn't helped. I know it's working cause it makes at least a hundred successful calls before it fails. Is there anything i can do to stop this error?

Update
I printed out the request and response headers hoping to see an error in there. But it appears they are fine:

HTTP/1.1 200 OK
Date: Wed, 25 Sep 2013 21:00:12 GMT
Server: Apache/2.2.15 (CentOS)
X-Powered-By: PHP/5.3.3
Content-Length: 516
Connection: close
Content-Type: text/xml; charset=UTF-8

as far as example code goes the actual script is crazy long, but the basic premise is this:

ini_set('default_socket_timeout', 120);
$client = new SoapClient($wsdl,array(
    'trace' =>true,
    'connection_timeout' => 500000,
    'cache_wsdl' => WSDL_CACHE_BOTH,
    'keep_alive' => true,
));
while(!$finished) {
    $finished = $client->someSoapFunction($data);
}

someSoapFunction() will return valid data for 100 of connections and then randomly return me the above error. The time it runs for is less than either of the set timeouts. I'm getting no errors in my php or apache error logs. I'm stumped.

Precipitin answered 25/9, 2013 at 16:18 Comment(1)
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself.Furcula
H
7

I know it is an old question, but perhaps my solution can be useful to others. I had the same problem and by changing the 'keep_alive' parameter to false in the creation of the SoapClient object, my problem was solved:

$client = new SoapClient($wsdl,array(
'trace' =>true,
'connection_timeout' => 500000,
'cache_wsdl' => WSDL_CACHE_BOTH,
'keep_alive' => false,
));
Hyperbole answered 27/1, 2014 at 11:26 Comment(2)
as far as i know this solution works only for php >= 5.4 as in lower versions the keep_alive option is not available. However it should be availabla in the configuration of your web serverBackstay
Thanks a ton, after 3 days of searching this finally solved our problems.Mac

© 2022 - 2024 — McMap. All rights reserved.