Hello Guys!
I’m working with NodeJs and MongoDB and I’m connecting to MongoDB through Mongoose driver.
My setup:
- NodeJS MongoDB Driver : 3.6.3
- Mongoose : 5.10.0
Below is my connections options:-
{
autoIndex: false,
promiseLibrary: Promise,
poolSize: 10,
autoReconnect: true,
reconnectTries: 30,
reconnectInterval: 1 * 1000,
connectTimeoutMS: 180 * 1000,
socketTimeoutMS: 180 * 1000,
keepAlive: true,
keepAliveInitialDelay: 10 * 1000,
useNewUrlParser: true
}
Below is my connection string:-
mongodb+srv://${DB_USERNAME}:${DB_PASSWORD_ENCRYPTED)}@${DB_URI}/${mongoose.DB}?retryWrites=true&w=majority
I’m getting connection 9 to XXXX-XXXX-XXXX-shard-00-01.dkvup.mongodb.net:27017 timed out Error for one of the API.
Can anyone assist me on what causing the above error and possibly the best connection configuration on production environment to avoid such errors.