我正在连接到网络服务以获取一些数据。我有大约 20 万个作业的请求队列,一个工作人员正在处理它。处理时间为每秒 2-3 次调用。在大约 500-1000 次调用后,它开始收到 SoapFault 异常并显示以下消息:Could not connect to host
。即使出现此错误,我也能够正确地 ping 网络服务服务器。
当我禁用 soap 缓存时,问题仍然存在,但错误更改为 Parsing WSDL: Couldn't load from 'http://thewebservice.com/method/Service.asmx?WSDL' : failed to加载外部实体
连接代码:
$client = new SoapClient('http://thewebservice.com/method/Service.asmx?WSDL');
$response = $client->__soapCall('method name', $parameters)
我的工作对象:
- PHP 7.0.11
- Lumen (5.2.9)(Laravel 组件 5.2.*)
最佳答案
在我的例子中,问题是同时打开的连接太多。我通过 keep_alive
选项修复了它:
$client = new SoapClient('http://thewebservice.com/method/Service.asmx?WSDL', ['keep_alive' => false]);
$response = $client->__soapCall('method name', $parameters)
关于php - 无法连接到主机,某些请求后出现 SoapFault 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40884866/