Gearman throws GEARMAN_COULD_NOT_CONNECT on php example

Asked by Lorenzo Marcon

Hello,

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

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

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 the echo example in the pecl package, the worker starts 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

In the gearman daemon's log there is no sign of activity for this php tests, while it logged all previous examples I tried.

How can I fix this error? Thanks.

Question information

Language:
English Edit question
Status:
Answered
For:
Gearman Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
LornaJane (j-launchpad-lornajane-net) said :
#1

I had exactly the same problem and (mine at least) it was due to a change in the GearmanClient::addServers() method. This at one time accepted plain IP addresses, but now requires the port number to be given. So if you have a line like this:

$client->addServers('127.0.0.1');

This should now be:

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

I'm not sure exactly what changed or when but I observed this when moving from Ubuntu 12.04 to 12.10 which brings PHP from 5.3 to 5.4 and I also installed the newest PHP pecl library (version 1.1.1) and gearmand 1.1.5 which I compiled as the versions in aptitude were too old. Hope that helps someone!

Can you help with this problem?

Provide an answer of your own, or ask Lorenzo Marcon for more information if necessary.

To post a message you must log in.