本文介绍了PHP的肥皂错误获取HTTP头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个通过SOAP连接处理大量数据的PHP脚本.如果脚本没有遇到任何错误,则估计其总运行时间为几天.我遇到的问题是脚本将运行一段时间,从一个小时到一天不等,然后SOAP连接将因错误"error fetching http headers"而消失.

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".

我看过很多文章建议增加 default_socket_timeout 设置,我已经尝试过了.它没有帮助.我知道它是有效的,因为它在失败之前至少进行了一百次成功的呼叫.我有什么办法可以阻止此错误?

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:

就示例代码而言,实际脚本太疯狂了,但是基本前提是:

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()将返回100个连接的有效数据,然后随机返回上述错误.它运行的时间少于任何一个设置的超时时间.我的php或apache错误日志中没有错误.我很困惑.

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.

推荐答案

我知道这是一个老问题,但也许我的解决方案可能对其他人有用.我遇到了同样的问题,通过在创建SoapClient对象时将'keep_alive'参数更改为false,解决了我的问题:

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,
));

这篇关于PHP的肥皂错误获取HTTP头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 11:34
查看更多