Problem with Gearman: GEARMAN_COULD_NOT_CONNECT

2019-06-14 12:19发布

问题:

I've installed gearman using "apt-get install gearman-server" and than build the PHP PECL.

If i try the worker:

$ gearman -w -f wc -- wc -l

It starts waiting. right.

But if i try to start a job (as descriped in the tutorial)

$ gearman -f wc < /etc/passwd

it says:

gearman: gearman_client_run_tasks : flush(GEARMAN_COULD_NOT_CONNECT) 127.0.0.1:4730 -> libgearman/connection.cc:480

And if i try the PHP str_rev demo descriped in the tutorial it gives me the very same error.

PHP Warning: GearmanClient::do(): flush(GEARMAN_COULD_NOT_CONNECT) 127.0.0.1:4730 -> libgearman/connection.cc:480 in /root/client.php on line 4

Here's the tutorial i've used: http://gearman.org/index.php?id=getting_started

Can someone help me?

Edit: Ok. I did the following: "apt-get remove gearman-server" and then "apt-get install gearman-job-server". Now the error is gone. But Another Problem: Both, Worker and Client, are now freezing. Just as they wait for something. Can someone help me?

回答1:

I had the same problem when working quickly through the example. It sounds like you don't have gearmand running - that's the process that will find available workers to do your job. Remember there are 3 parts - the client who wants the work done, the worker who will do the work, and the job-server (aka gearmand) who will find an available worker for the client's request.



回答2:

explicitly call: $worker->addServer("localhost",4730);