编程语言
首页 > 编程语言> > Gearman在php示例中抛出GEARMAN_COULD_NOT_CONNECT

Gearman在php示例中抛出GEARMAN_COULD_NOT_CONNECT

作者:互联网

我在服务器上安装了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示例,该工作程序正确启动:

[~/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测试没有活动迹象,而它记录了我尝试过的所有先前示例.

如何解决此错误?谢谢.

解决方法:

尽管php文档说了什么,但您应该始终使用addServer(“ 127.0.0.1”,4730),而不要使用addServer().

标签:gearman,php
来源: https://codeday.me/bug/20191031/1974603.html