Gearman throws GEARMAN_COULD_NOT_CONNECT using php example

I installed gearmand 1.1.5 on my server and tried the examples provided with the installation after starting the server. They work pretty well (the echo example works, the opposite doesn't work as expected, but doesn't give any error).

Then I installed the php wrapper using pecl. The version is the latest stable (1.1.1). Obviously I added an extension to php.ini and my output for php -info | grep:

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

      

Then I tried an echo example in the pecl package, the worker started correctly:

[~/gearman-1.1.1/examples]# php reverse_worker.php 
Starting
Waiting for job...

      

the client instead gives me the following error:

[~/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

      

There is no sign of activity in the gearman daemon log for these php tests, while it logs all the previous examples I've tried.

How can I fix this error? Thank.

+3


source to share


2 answers


You should always use addServer("127.0.0.1", 4730)

and not addServer()

, despite what the php documentation says.



+4


source


If you have used something like this

$ client-> addServers ('127.0.0.1', 4730);

or

$ client-> addServers ();



and still it didn't work, then use something like this

$ client-> addServers ('127.0.0.1:4730');

PS - I used localhost IP, this can be replaced with the actual host IP.

0


source







All Articles