2012-01-28 38 views
1

我試圖使用PHP Resque(其中通過redisent使用Redis的),但我不斷收到此錯誤:Resque PHP(Redis的錯誤?)

Warning: fsockopen() expects parameter 2 to be long, string given in 
/home/***/public_html/codes/ao/resque/lib/Redisent/Redisent.php on line 56 

Fatal error: Uncaught exception 'Exception' with message ' - ' in 
/home/***/public_html/codes/ao/resque/lib/Redisent/Redisent.php:58 Stack trace: #0 
/home/***/public_html/codes/ao/resque/lib/Redisent/Redisent.php(52): Redisent- 
>establishConnection() #1 /home/***/public_html/codes/ao/resque/lib/Resque.php(38): 
Redisent->__construct('redis', '//***') #2 /home/***/public_html/cons/db.php(6): 
Resque::setBackend('redis://***...') #3 {main} thrown in 
/home/***/public_html/codes/ao/resque/lib/Redisent/Redisent.php on line 58 

我無法弄清楚什麼是錯的。請幫幫我!

回答

2

錯誤轉儲的第一行顯示了問題。

fsockopen() expects parameter 2 to be long, string given in 
    in /home/***/public_html/codes/ao/resque/lib/Redisent/Redisent.php on line 56 

fsockopen()的第二個參數被認爲是一個端口號。不知何故,你傳遞一個字符串到它。

以下錯誤的其餘部分僅僅是由於連接失敗。

在看Redisent.php source code,看起來你必須傳遞一個無效參數給你的Redisent對象的構造函數。

在源代碼中,你有這樣的:

$foo = new Redisent('hostname', '32323'); // See the bug? 

...確保第二個參數是不是字符串。

以下是正確的:

$foo = new Redisent('hostname', 32323); // no quotes around port number! 
+0

當我'運行:的fsockopen('Redis的:// neex1233:********** ******:'9134 /');'我得到這個錯誤: '警告:fsockopen()[function.fsockopen]:無法連接到redis:// neex1233:*** ************************ @ stingfish.redistogo.com:9154(無法找到套接字傳輸「redis」 - 你忘了啓用它時你在第6行配置了/home/username/public_html/cons/db.php中的PHP?)我猜這與它有關。 – user1174824 2012-01-28 15:25:02

+0

這是另一個明顯的例子。 丟失「redis://」前綴。第一個參數就是主機名。 Redisent.php不添加一個PHP套接字傳輸。在Redisent文檔中,這是完全正確的。 請將我的原始答覆標記爲已接受。謝謝! – 2012-01-29 21:31:19