0
有人告訴一例中設定connectTimeoutMS不同的價值如何給出不同的結果?的MongoDB的NodeJS connectTimeoutMS
應用程序啓動:
var myDB = null;
var options = { server: { socketOptions: { connectTimeoutMS: 5000 }}};
MongoClient.connect(CONFIG.connectionString,options, function(err, db) {
if (err) {
throw err;
}
db.on('error', function(err){
console.error('can not establish connection');
});
myDB = db;
});
後來我停止蒙戈服務(在Windows上),然後執行它使用
myDB.collection('someCollection').find({}).toArray(function(err){
console.log('never called after stoping mongo service. Shouldnt it call with err argument?',err);
});
我希望 '指定者' 內的回調代碼執行基於
connectTimeoutMS
屬性。爲什麼不叫它?如果
connectTimeoutMS
意味着別的東西,我怎麼能看到不同的效果,當我將它設置爲不同的值。