I have a web application running on Node, express and MongoDB. I use mongoose as the ODM. When i tested my application with mongodb version v3.0.1 it runs fine and throws no errors. But when i run the same code v3.2.10 i get a connection timeout after some time.
我有一个在Node、express和MongoDB上运行的web应用程序。我用猫鼬作为ODM。当我用mongodb v3.0.1测试我的应用程序时,它运行良好,不会抛出错误。但是当我运行相同的代码v3.2.10时,我将在一段时间后获得连接超时。
I get the following Error :
我得到以下错误:
Error: connection timeout at null.<anonymous> (/webapp/node_module/mongoose/lib/drivers/node-mongodb-native/connection.js:186:17)
I use mongoose.connect for the db connection to the local mongodb instance. Has anything changed in the way of connection ?
我用猫鼬。连接到本地mongodb实例的db连接。联系方式有什么变化吗?
1 个解决方案
#1
14
I had this problem a while ago. It all depends on which version of mongoose
and mongodb-core
you are using. Right now, you have to specify the following parameters:
我刚才有这个问题。这一切都取决于您使用的是哪个版本的mongoose和mongodb-core。目前,您必须指定以下参数:
mongoose.connect("mongodb://user:password@address/db", {
server: {
socketOptions: {
socketTimeoutMS: 0,
connectionTimeout: 0
}
}
});
However, just yesterday, the correct parameters where
然而,就在昨天,正确的参数在哪里。
mongoose.connect("mongodb://user:password@address/db", {
server: {
socketOptions: {
socketTimeoutMS: 0,
connectTimeoutMS: 0
}
}
});
I don't really know what to believe in anymore..
我真的不知道该相信什么了。
#1
14
I had this problem a while ago. It all depends on which version of mongoose
and mongodb-core
you are using. Right now, you have to specify the following parameters:
我刚才有这个问题。这一切都取决于您使用的是哪个版本的mongoose和mongodb-core。目前,您必须指定以下参数:
mongoose.connect("mongodb://user:password@address/db", {
server: {
socketOptions: {
socketTimeoutMS: 0,
connectionTimeout: 0
}
}
});
However, just yesterday, the correct parameters where
然而,就在昨天,正确的参数在哪里。
mongoose.connect("mongodb://user:password@address/db", {
server: {
socketOptions: {
socketTimeoutMS: 0,
connectTimeoutMS: 0
}
}
});
I don't really know what to believe in anymore..
我真的不知道该相信什么了。