2013-02-07 27 views
3

我在我的服務器上安裝了gearmand 1.1.5,並嘗試啓動服務器後安裝時提供的示例。他們工作得相當正確(回聲示例工作,反向不按預期工作,但不會給出任何錯誤)。Gearman在php示例中拋出GEARMAN_COULD_NOT_CONNECT

然後我使用pecl安裝了php包裝器。該版本是最後一個穩定版本(1.1.1)。很顯然,我添加了擴展爲php.ini,和我的php --info | grep的Gearman的輸出是:

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 

然後我試圖在PECL包回聲例如,工人可以正常啓動:

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

客戶端,而是給了我以下錯誤:

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

在Gearman的守護程序的日誌沒有任何活動的跡象了這個PHP測試,而其記錄的所有前面的例子我試過了。

我該如何解決這個錯誤?謝謝。

+0

關於gearman的好博客..'http:// www.brijneet.com/2011/gearman /' –

+0

你能提供你用來連接的代碼嗎?我確實發現爲本地主機修復的問題添加了127.0.0.1 –

+0

我們殺死並重啓了守護進程,現在它正在工作。也許這是一個端口綁定/主機解析問題?我們做了很多測試,可能是搞砸了。我還在/ etc/hosts(127.0.0.1 localhost)中添加了一行。感謝您的建議 –

回答

4

儘管php文檔中提到了什麼,但您應該始終使用addServer("127.0.0.1", 4730)而不是addServer()

0

在情況下,如果你使用了這樣的事情

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

$client->addServers();

和它仍然沒有工作,然後使用類似這樣

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

PS - 我已經使用本地主機IP,這可以用實際的主機IP來代替。