Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gearman gives me GEARMAN_COULD_NOT_CONNECT, it is definitely running

My dev server is Debian Squeeze and I'm running Gearman 1.1.5 which I compiled from source along with the php pecl extension v1.1.1

If I run the reverse_client.php script I get the GEARMAN_COULD_NOT_CONNECT error.

PHP Warning: GearmanClient::do(): send_packet(GEARMAN_COULD_NOT_CONNECT) Failed to send server-options packet -> libgearman/connection.cc:430 in /home/bealers/build/gearman-1.1.1/examples/reverse_client.php on line 26

There are a few similar posts on here about this and they all point to GM not running.

It is definitely running.

I'm starting it with these params:

PARAMS="--queue-type=MySQL --mysql-db=test_db --mysql-user=gearman --mysql-password=gearman"

If I drop the gearman_queue table in test_db then restart the daemon the table is recreated, so its mysql connection is fine and it's clearly starting.

I can also telnet to 4730 on localhost, so there's no firewall issue.

Initially GM had problems starting because it was starting before mysql, so I edited the init script

### BEGIN INIT INFO
# Provides:          gearman-job-server
# Required-Start:    $network $remote_fs $syslog mysql

and an update-rd.c gearman-job-server defaults sets it to start after and it starts fine on boot up now.

The only other thing I can think of is that initially I'd installed via apt but the version was to old so I removed it and compiled from source. /usr/sbin/gearmand no longer exists the only version is /usr/local/sbin/gearmand

ps ax | grep gearman shows only one process running.

Netstat shows only one process running`

tcp 0 0 *:4730 *:* LISTEN 2325/gearmand

The PECL lib seems fine:

php -i | grep gearman

/etc/php5/cli/conf.d/gearman.ini,
gearman
gearman support => enabled
libgearman version => 1.1.5

I'm out of ideas

like image 968
Darren Beale Avatar asked Feb 14 '13 20:02

Darren Beale


2 Answers

I had the same problem and recently solved them after a couple days of frustration (hard to troubleshoot since there are three processes to worry about :-)

It appears (at least in my case) that the PHP documentation for GearmanClient::addServer() and GearmanWorker::addServer() is incorrect. Specifically, the docs seem to imply that hostname and port number are optional and that it will use localhost and port 4730 as defaults if you do not specify them. This never works - it suddenly occurred to me today to try explicitly specifying them for both client and worker processes and everything started working.

Try specifying all values for hostnames and ports and see if this works for you.

like image 136
Eno Avatar answered Sep 29 '22 08:09

Eno


In case if you have used something like this

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

or

$client->addServers();

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.

like image 42
Jatin Dhoot Avatar answered Sep 29 '22 08:09

Jatin Dhoot