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
尝试作为参数传递:
$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();
一行也适用于我:
$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();
I've Googled everywhere but no one has posted a solution, they all say to set the timeout in the config but how do you do this?
How do I reset/override this setting from my XMLRPC client or server?
Here is what I'm trying:
$server = new Zend_XmlRpc_Client('http://127.0.0.1/xmlrpc');
$client = $server->getProxy();
// Increasing the timeout
$client->setConfig(array('timeout'=>30));
Here is the error:
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
Trying to pass as arg:
$server = new Zend_XmlRpc_Client('http://127.0.0.1/xmlrpc', array('timeout'=>30));
Here is the error:
Catchable fatal error: Argument 2 passed to
Zend_XmlRpc_Client::__construct() must be an
instance of Zend_Http_Client
Found the solution and here it is:
$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 works for me as well:
$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();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Zend 文档 指定允许您使用的配置参数。我猜你可以简单地将超时从 10 秒增加到 20 或 30 秒。无论什么适合你。
或者:
更新 - Zend_Http_Client 由 Zend_XmlRpc_Client 使用。您可以通过 Zend_XmlRpc_Client 对象设置和访问 Zend_Http_Client。
我还没有对此进行测试,所以我不知道它是否会起作用,但您也可以使用 setHttpClient() 方法将您自己的 Zend_Http_Client 对象传递给 Zend_XmlRpc_Client 对象,如 Zend Zend_XmlRpc_Client 的文档页面。
Zend documentation specifies the configuration parameters that you are allowed to use. I would guess that you can simply increase the timeout from 10 seconds to 20 or 30. Whatever is appropriate for you.
or:
UPDATE - Zend_Http_Client is used by Zend_XmlRpc_Client. You can set and access the Zend_Http_Client via the Zend_XmlRpc_Client object.
I haven't tested this so I don't know that it will work but you can also pass in your own Zend_Http_Client object to a Zend_XmlRpc_Client object using the setHttpClient() method as described (rather arcanely) at the bottom of the Zend documentation page for Zend_XmlRpc_Client.
无论您使用什么客户端:
其中
$client
可以是 Rest 或 Soap 客户端。另外,这里的答案之一有一个导致痛苦的小错误:
Whatever client you're using:
where
$client
could be a Rest or Soap Client.Also, one of the answers here has a minor error that causes pain:
这些答案是好的,尽管自 Zend HTTP 2.0 (2012 年发布 - see diff )它是:
$client->getHttpClient()->setOptions(array('timeout'=>30));
Those answers are alright, though since Zend HTTP 2.0 (released in 2012 - see diff) it is :
$client->getHttpClient()->setOptions(array('timeout'=>30));