php – XMLRPC Zend_Http_Client_Adapter_Exception’,带有消息’读取10秒后超时
作者:互联网
我在谷歌搜索过,但没有人发布解决方案,他们都说在配置中设置超时,但你怎么做?
如何从XMLRPC客户端或服务器重置/覆盖此设置?
这是我正在尝试的:
$server = new Zend_XmlRpc_Client('http://127.0.0.1/xmlrpc');
$client = $server->getProxy();
// Increasing the timeout
$client->setConfig(array('timeout'=>30));
这是错误:
Fatal error: Uncaught exception 'Zend_XmlRpc_Client_FaultException'
with message 'Method "setConfig" does not exist'
in /usr/share/php/libzend-framework-php/Zend/XmlRpc/Client.php:370
试图传递为arg:
$server = new Zend_XmlRpc_Client('http://127.0.0.1/xmlrpc', array('timeout'=>30));
这是错误:
Catchable fatal error: Argument 2 passed to
Zend_XmlRpc_Client::__construct() must be an
instance of Zend_Http_Client
找到解决方案,这里是:
$server = new Zend_XmlRpc_Client('http://127.0.0.1/xmlrpc');
// Get the HTTP Client used by the XMLRPC client
$http_client = $server->getHttpClient();
// Increasing the HTTP timeout
$http_client->setConfig(array('timeout'=>30));
$client = $server->getProxy();
One Line也适用于我:
$server = new Zend_XmlRpc_Client('http://127.0.0.1/xmlrpc');
// Get the HTTP Client used by the XMLRPC client and increasing the HTTP timeout
$server->getHttpClient()->setConfig(array('timeout'=>30));
$client = $server->getProxy();
解决方法:
Zend documentation指定允许使用的配置参数.我猜你可以简单地将超时时间从10秒增加到20或30.无论什么适合你.
$client = new Zend_Http_Client('http://example.org', array('timeout' => 30));
要么:
$client->setConfig(array('timeout'=>30));
更新 – Zend_Http_Client由Zend_XmlRpc_Client使用.您可以通过Zend_XmlRpc_Client对象设置和访问Zend_Http_Client.
$xmlrpc_client = new Zend_XmlRpc_Client('http://127.0.0.1/xmlrpc');
$xmlrpc_client->getHttpClient()->setConfig(array('timeout'=>30'));
我没有测试过这个,所以我不知道它会起作用,但你也可以使用setHttpClient()方法将你自己的Zend_Http_Client对象传递给Zend_XmlRpc_Client对象,如Zend documentation page for Zend_XmlRpc_Client底部所描述的那样(相当古怪).
标签:php,httpwebrequest,config,zend-framework,xml-rpc 来源: https://codeday.me/bug/20190713/1447957.html