I've got a problem to connect my socketIO application (made with nodeJS) with my mongoDB.
I try to connect on an remote server, but its throws me error
Here's my code (there's no user/password set in the mongoDB) :
var url = "mongodb://192.168.1.5:27017/DB"
MongoClient.connect(url, function(err, db) {
console.log("test")
if (!err) {
console.log("test");
}
else {
console.dir(err)
throw err
}
// db.close();
});
And here's when I launch the server and I tried to launch the app in a navigator :
Server listening at port 80:
{ [MongoError: connect ECONNREFUSED] name: 'MongoError', message: 'connect ECONNREFUSED' }
/root/fys-realtime/examples/chat/node_modules/mongodb/lib/server.js:228
process.nextTick(function() { throw err; })
^
Error
at Error.MongoError (/root/fys-realtime/examples/chat/node_modules/mongodb/node_modules/mongodb-core/lib/error.js:13:17)
at Server.destroy (/root/fys-realtime/examples/chat/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:629:47)
at Server.close (/root/fys-realtime/examples/chat/node_modules/mongodb/lib/server.js:344:17)
at Db.close (/root/fys-realtime/examples/chat/node_modules/mongodb/lib/db.js:267:19)
at /root/fys-realtime/examples/chat/node_modules/mongodb/lib/db.js:196:12
at null.<anonymous> (/root/fys-realtime/examples/chat/node_modules/mongodb/lib/server.js:226:9)
at g (events.js:180:16)
at emit (events.js:98:17)
at null.<anonymous> (/root/fys-realtime/examples/chat/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:238:68)
at g (events.js:180:16)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…