Should MongooseJS be emitting events on replica set disconnection?
With a single server setup, I receive events from the driver.
mongoose.connect('mongodb://localhost/mydb');
mongoose.connection.on('disconnected', function() {...});
mongoose.connection.on('error', function(err) {...});
When using a replica set
(mongoose.connect('mongodb://localhost:27017/mydb,mongodb://localhost:27018/mydb');),
shutting down all connected set members doesn't trigger those same events.
I'm not very familiar with the internals of the native driver and I'm
wondering if this is a bug or if I need to manually detect this condition.
I'm using Mongoose 3.6.17 (mongodb driver 1.3.18)
Sans mongoose, I tried this with the same results (no events from a
replica set).
require('mongodb').MongoClient.connect("mongodb://localhost:27017,localhost:27018/mydb",
function(err, db) {
if (db) {
db.on('disconnected', function() {
console.log('disconnected');
}).on('error', function(err) {
console.log('error');
});
}
});
No comments:
Post a Comment