我在向mongo执行非常大量(数千)的异步查询时遇到了问题 我收到以下错误
throw er; // Unhandled 'error' event
^
MongoError: connection 4 to localhost:27017 timed out
我还尝试了不同的连接选项值,增加和减少它们但仍然出现错误
app.js中的连接代码部分
var MongoOptions = {
socketTimeoutMS: 0,
connectTimeoutMS: 0,
keepAlive: true,
reconnectTries: 30,
poolSize: 10
};
mongoose.connect(Config.MONGO_DB_MOJ_CONNECTION, MongoOptions).then(function () {
console.log('connected to mongo');
}, function (err) {
//err handle
});
答案 0 :(得分:0)
试
{ keepAlive: 0, connectTimeoutMS: 0}