I have two droplets running. One is running node and the other is running MongoDB. The node droplet connects to the MongoDB droplet over private networking using mongoose. If the MongoDB droplet powers off, the mongoose connection will disconnect and when the MongoDB droplet powers on, the mongoose connection will reconnect. The problem is that when the MongoDB droplet simply reboots, the mongoose connection does not disconnect. The connection does not close but is completely unusable.
var options = { server: { auto_reconnect: true, reconnectInterval: 1000, reconnectTries: Infinity, socketOptions: { keepAlive: 1, connectTimeoutMS: 1000 } } };
var db = mongoose.createConnection(‘snip’, options);
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello,
This looks good, what errors are you getting when trying to connect after a reboot or pull information? Have you tried increasing or decreasing the connectTimeoutMS or reconnectInterval? It’s important to understand when asking for assistance or advice to provide as much information as you can.
Currently I’m not sure how to replicate the problem you are having, so we need a bit more information. Have you tried connecting outside the node application? Perhaps it’s at the application level?
Are the reboots planned and initiated by you, unplanned, both?
If you can provide more information, a better solution may be available, but it’s a bit difficult with the limited information.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.