Error in connecting to document DB intermittently

0

Hi,

I am facing the below exception intermittently. I am using the connection as below.

“errorMessage”:“MongoTimeoutError: Server selection timed out after 30000 ms”,“reason”:{“errorType”:“MongoTimeoutError”,“errorMessage”:“Server selection timed out after 30000 ms”,“name”:“MongoTimeoutError”,“stack”:[“MongoTimeoutError: Server selection timed out after 30000 ms”," at Timeout.setTimeout [as _onTimeout] (/var/task/node_modules/mongodb/lib/core/sdam/server_selection.js:308:9)"," at ontimeout (timers.js:436:11)"," at tryOnTimeout (timers.js:300:5)"," at listOnTimeout (timers.js:263:5)"," at Timer.processTimers (timers.js:223:10)"]},“promise”:{},“stack”:[“Runtime.UnhandledPromiseRejection: MongoTimeoutError: Server selection timed out after 30000 ms”," at process.on (/var/runtime/index.js:37:15)"," at process.emit (events.js:198:13)"," at process.EventEmitter.emit (domain.js:448:20)"," at emitPromiseRejectionWarnings (internal/process/promises.js:140:18)"," at process._tickCallback (internal/process/next_tick.js:69:34)"]}

let connectionString = mongodb://${data.username}:${data.password}@${clusterEndpoint}:27017/?ssl=true&ssl_ca_certs=rds-combined-ca-bundle.pem&replicaSet=rs0;
return new Promise((resolve, reject) => {
mongodb.connect(connectionString, { useUnifiedTopology: true }, (err, res) => {
if (err) {
reject(err);
} else {
resolve(res);
}
})
});

已提問 4 年前檢視次數 2596 次
2 個答案
0

Looking at the errors below, seems like your connection is timing out. Timeouts could happen if 1/ The client where your Node.js app is running is in a different VPC/different region than your Amazon DocumentDB cluster 2/ The security group associated with your cluster does not allow inbound connections on port 27017. You mentioned you see the error intermittently. Are there any patterns, triggers that typically cause this? Are there any changes in your environment that would cause this intermittently?

Edited by: AWSMeetB on Sep 10, 2020 11:19 PM

AWS
已回答 4 年前
0

I am also facing this issue intermittently without any pattern. I am using pymongo python client to connect with docdb.

已回答 3 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南