我偶然發現大約貓鼬好奇的問題連接mongodb的,它生成細節錯誤,貓鼬的下面貓鼬輸出的誤差「錯誤:連接關閉」
e:\Mentor_Resources\node\node_twitter_bootstrap>node app
Express server listening on port 3000
Trace: error occure when start to connect dbError: connection closed
at e:\Mentor_Resources\node\node_twitter_bootstrap\server\module\word.js:14:
17
at Connection.open (e:\Mentor_Resources\node\node_twitter_bootstrap\node_mod
ules\mongoose\lib\connection.js:201:5)
at Db.open (e:\Mentor_Resources\node\node_twitter_bootstrap\node_modules\mon
goose\node_modules\mongodb\lib\mongodb\db.js:247:16)
at Server.connect.connectionPool.on.server._serverState (e:\Mentor_Resources
\node\node_twitter_bootstrap\node_modules\mongoose\node_modules\mongodb\lib\mong
odb\connection\server.js:413:7)
at EventEmitter.emit (events.js:115:20)
at connection.on.connectionStatus (e:\Mentor_Resources\node\node_twitter_boo
tstrap\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\connect
ion_pool.js:108:15)
at EventEmitter.emit (events.js:91:17)
at Socket.closeHandler (e:\Mentor_Resources\node\node_twitter_bootstrap\node
_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\connection.js:401:
12)
at Socket.EventEmitter.emit (events.js:88:17)
at Socket._destroy.destroyed (net.js:364:10)
代碼段是:
var mongoose = require('mongoose');
mongoose.connect("mongodb://localhost/word-sentence",function(err) {
if(err)
console.trace('error occure when start to connect db' + err);
});
我相信mongodb是開放的,我重新啓動mongodb幾次,但錯誤仍然存在,所以我重新啓動我的Windows XP,並再次嘗試問題消失,一切正常,所以我想知道爲什麼?
很難肯定地說,但我的猜測是另一個應用程序已經在使用的27017蒙戈的默認TCP端口在MongoDB服務器可以綁定到它之前。 – JohnnyHK 2012-08-13 04:49:07
不,我用「mongo」命令行,沒關係,「show dbs」也沒問題 – clevertension 2012-08-13 05:43:45
'netstat -bano'的輸出是什麼?您可以將其發佈到pastebin或類似文件中 – 2012-08-13 09:25:47