2011-05-14 29 views
2

如果我取消並在默認端口上重新啓動我的mongodb,則重新連接好,並且沒有任何問題。
當我將27018端口上這樣做,似乎在我的bash窗口重新連接和我在重啓的結束得到這樣的說法:當我停止並重新啓動我的mongod服務時,爲什麼會出現應用程序錯誤

initandlisten] waiting for connections on port 27018 
websvr] web admin interface listening on port 28018 

但是當我運行我的應用程序我得到這樣

錯誤
Operation failed with the following exception: connection closed 

Operation failed with the following exception: Broken pipe - send(2) 
:10:in `synchronize' 
+0

你是說「當應用程序配置爲在默認端口27017使用monogdb時,它在mongodb重新啓動時重新連接,但沒有配置爲端口27018時」?我不相信你;) – oma 2011-05-14 21:05:34

回答

2

Mongoid創建一個到MongoDB的進程的連接,然後保持這個局面性能reaso納秒。如果服務器關閉,服務器端的連接斷開,客戶端無法再發送請求。

在您的Mongoid configuration中,您可以將連接配置爲可回溯,以便在出現故障時重試失敗的連接。

max_retries_on_connection_failure [2] 

方括號內的數字是在引發例外之前重試的次數(每次嘗試之間的間隔爲半秒)。

相關問題