New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto reconnect #306
Comments
Agree. I am using node_redis module and it has "connected" field and "on error" callback. If disconnect happened - "connected" field set to false and node_redis try to connect repeatedly firing "on error" until the connection established. Maybe Mongoose should work on the same model. |
this might be helpful: https://gist.github.com/1058819 |
The native mongodb driver has an auto reconnect feature, but Mongoose doesn't provide the option to pass the flag that turns it on when the connection is established. This is a workaround to enable it:
|
@rpbertp13, that's much nicer than my solution thanks! |
@rpbertp13 last time I tried that (several months ago), that didn't do anything. perhaps it's working now. |
Works for me with the current version (0.9.6.1). The code is definitely there: https://github.com/LearnBoost/mongoose/blob/master/support/node-mongodb-native/lib/mongodb/connection.js#L233-233 |
cool. I'll give it a try again but I hink this issue should be left open until the issue is directly addressed by mongoose, at the API level even. |
Using 1.5. throws: |
This syntax worked for me: dbConnection = mongoose.createConnection(....);
dbConnection.db.serverConfig.options.auto_reconnect = true; See also: #410 |
Just merged pull #410 into branch v1.x in this morning. Options can now be passed to Server, ReplSetServer, and Db. The |
Mongoose-based apps currently has to be restarted when connection fails, times out, or when
mongod
restarts. There has to be a better way.The text was updated successfully, but these errors were encountered: