I have created a function that handles the connection with multiple MongoDB databases. It worked well, but suddenly before 3 - 4 weeks mongoDb started throwing errors of connection timeout and reset pool (Below is the full error)
I have whitelisted my IP as well as allowed all IPs for now.
MongoNetworkError: connect ETIMEDOUT 3.108.0.179:27017 at connectionFailureError (G:\ALIAN PROJECT\alian-hub-api\node_modules\mongodb\lib\cmap\connect.js:367:20) at TLSSocket.<anonymous> (G:\ALIAN PROJECT\alian-hub-api\node_modules\mongodb\lib\cmap\connect.js:290:22) at Object.onceWrapper (node:events:629:26) at TLSSocket.emit (node:events:514:28) at TLSSocket.emit (node:domain:489:12) at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { cause: Error: connect ETIMEDOUT 3.108.0.179:27017 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16) { errno: -4039, code: 'ETIMEDOUT', syscall: 'connect', address: '3.108.0.179', port: 27017 }, connectionGeneration: 0, [Symbol(errorLabels)]: Set(1) { 'ResetPool' } }
Sometimes even at the start of my node server it throws this error
here is the configration for connection
const connection = await mongoose.createConnection(`${process.env.MONGODB_URL}/${db}`, { maxPoolSize: 60, useNewUrlParser: true, connectTimeoutMS: 50000 })
connection.on('connected', () => { logger.info(`MONGO CONNECTION ${db}: connected`); console.log(`MONGO CONNECTION ${db}: connected`); resolve(connection); });
//…Other handers for connection
connection.on('error', (error) => { logger.error(`MONGO CONNECTION: error >> ${JSON.stringify(error)}`) }); ```
I also dropped these questions in mongoSupport but still no answers were found.