Mongoose 'reconnected' Event is not fired after 'close' event is getting fired after the second time. How can I increase the time to always retry?
close: Emitted after we disconnected and onClose (after this, if I start Mongo, it is not firing any event) executed on all of this connections models.
I finally found the answer for this, We need to use the server options of mongodb-native driver options like this.
var opts = {
server: {
auto_reconnect: true,
reconnectInterval: 5000,
reconnectTries: Infinity,
socketOptions: {
keepAlive: 1,
connectTimeoutMS: 10000
}
}
}
For more options follow this document: http://mongodb.github.io/node-mongodb-native/2.0/api/Server.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With