Lorenzo Marcon
Lorenzo Marcon

Reputation: 8169

Gearman throws GEARMAN_COULD_NOT_CONNECT on 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 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.

Upvotes: 3

Views: 2106

Answers (2)

Jatin Dhoot
Jatin Dhoot

Reputation: 4364

In case if you have used something like this

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

or

$client->addServers();

and still it didnt work then use something like this

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

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

Upvotes: 0

Eduards Cauna
Eduards Cauna

Reputation: 56

Your should always use addServer("127.0.0.1", 4730), not addServer(), despite what php documentation says.

Upvotes: 4

Related Questions