I'm using mongoskin as a wrapper to the native mongodb driver, auto_reconnect doesn't seem to work.
I'm creating the database:
var db = mongo.db(serverUrl, {
database: database,
auto_reconnect: true,
safe: true
});
I added a query on connection close to test it:
db.on('close', function(err) {
setTimeout(function() {
db.collection('users').findOne({short_id: '123'}, console.log);
}, 5000)
});
immediately after running the node process i'm killing and starting mongod, I'm getting '[Error: no open connections]' as the query result.
doesn't it suppose to auto_reconnect on connection lose ? or its trying to auto_reconnect immediately on connection close but mongod isn't up yet ?
can I reconnect manually or do I need to create a new server ?
Make sure you are using the latest node-mongodb-native (1.2.11) driver and it should work as you expect it to.