我在我的服务器上安装了gearmand 1.1.5,并在启动服务器后尝试了安装提供的示例。它们可以很好地工作( echo示例可以正常工作,反之亦然,但不会产生任何错误)。
然后我使用pecl安装了php包装器。该版本是最新的稳定版本(1.1.1)。显然,我向php.ini添加了扩展名,我的php --info|grep gearman输出是:
gearman
gearman support => enabled
libgearman version => 1.1.5
PWD => /root/gearman-1.1.1/examples
OLDPWD => /root/gearman-1.1.1
_SERVER["PWD"] => /root/gearman-1.1.1/examples
_SERVER["OLDPWD"] => /root/gearman-1.1.1然后我在pecl包中尝试了echo示例,worker正确启动:
[~/gearman-1.1.1/examples]# php reverse_worker.php
Starting
Waiting for job...相反,客户端给了我以下错误:
[~/gearman-1.1.1/examples]# php reverse_client.php
Starting
Sending job
PHP Warning: GearmanClient::do(): send_packet(GEARMAN_COULD_NOT_CONNECT) Failed to send server-options packet -> libgearman/connection.cc:430 in /root/gearman-1.1.1/examples/reverse_client.php on line 26
PHP Stack trace:
PHP 1. {main}() /root/gearman-1.1.1/examples/reverse_client.php:0
PHP 2. GearmanClient->do() /root/gearman-1.1.1/examples/reverse_client.php:26
Warning: GearmanClient::do(): send_packet(GEARMAN_COULD_NOT_CONNECT) Failed to send server-options packet -> libgearman/connection.cc:430 in /root/gearman-1.1.1/examples/reverse_client.php on line 26
Call Stack:
0.0001 228408 1. {main}() /root/gearman-1.1.1/examples/reverse_client.php:0
0.0003 229552 2. GearmanClient->do() /root/gearman-1.1.1/examples/reverse_client.php:26
RET: 26在gearman守护进程的日志中,没有显示此php测试的活动迹象,而它记录了我之前尝试过的所有示例。
如何修复此错误?谢谢。
发布于 2013-04-30 10:39:27
不管php文档怎么说,你应该始终使用addServer("127.0.0.1", 4730),而不是addServer()。
发布于 2016-04-18 19:46:02
以防您使用了下面这样的东西
$client->添加服务器(‘127.0.0.1’,4730);
或
$client->addServers();
它仍然不起作用,那就用下面这样的代码
$client->addServers('127.0.0.1:4730');
PS -I使用了本地主机IP,可以替换为实际的主机IP。
https://stackoverflow.com/questions/14749576
复制相似问题