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 年前2595 查看次数
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 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则