XMLRPC Zend_Http_Client_Adapter_Exception'带有消息“10 秒后读取超时”

发布于 2024-10-09 14:34:01 字数 1425 浏览 6 评论 0原文

我到处搜索,但没有人发布解决方案,他们都说在配置中设置超时,但你如何做到这一点?

如何从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

没︽人懂的悲伤 2024-10-16 14:34:01

Zend 文档 指定允许您使用的配置参数。我猜你可以简单地将超时从 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 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.

$client = new Zend_Http_Client('http://example.org', array('timeout' => 30));

or:

$client->setConfig(array('timeout'=>30));

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.

$xmlrpc_client = new Zend_XmlRpc_Client('http://127.0.0.1/xmlrpc');
$xmlrpc_client->getHttpClient()->setConfig(array('timeout'=>30'));

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.

垂暮老矣 2024-10-16 14:34:01

无论您使用什么客户端:

$client->getHttpClient()->setConfig(array('timeout'=>30));

其中 $client 可以是 Rest 或 Soap 客户端。

另外,这里的答案之一有一个导致痛苦的小错误:

client->getHttpClient()->setConfig(array('timeout'=>30')); - remove single quote after 30

Whatever client you're using:

$client->getHttpClient()->setConfig(array('timeout'=>30));

where $client could be a Rest or Soap Client.

Also, one of the answers here has a minor error that causes pain:

client->getHttpClient()->setConfig(array('timeout'=>30')); - remove single quote after 30
痞味浪人 2024-10-16 14:34:01

这些答案是好的,尽管自 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));

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文