Estoy tratando de averiguar cómo puedo hacer que mi aplicación nodejs/express se vuelva a conectar automáticamente a mongodb después de una pérdida de conexión. Me di cuenta de que mi aplicación pierde la conexión cuando pausa/detengo mi clúster mongodb y nunca me vuelvo a conectar, incluso cuando habilito el clúster. Por lo tanto, necesito reiniciar manualmente mi aplicación para volver a conectarme a mongodb. No es ideal para un entorno de producción.
Después de algunas investigaciones, he intentado configurar mi conexión de esta manera:
const options = { useNewUrlParser: true, useCreateIndex: true, useUnifiedTopology: true, useFindAndModify: false, autoIndex: true, autoReconnect:true, reconnectTries: Number.MAX_VALUE, reconnectInterval: 500, bufferMaxEntries: 0, connectTimeoutMS: 10000, socketTimeoutMS: 45000, } mongoose.connect(MONGO_URI, options);Pero me sale los siguientes errores:
(node:21749) DeprecationWarning: The option `autoReconnect` is incompatible with the unified topology, please read more by visiting http://bit. ly/2D8WfT6 ... (node:21749) DeprecationWarning: The option `reconnectTries` is incompatible with the unified topology, please read more by visiting http://bit. ly/2D8WfT6 ... (node:21749) DeprecationWarning: The option `reconnectInterval` is incompatible with the unified topology, please read more by visiting http://bit. ly/2D8WfT6Cualquier sugerencia ?