I am trying to connect to a DocumentDB instance from an Elastic Bean Stalk node.js instance.
I was able to connect to the cluster via Cloud9 after adding the security group allowing incoming 27017 connections.
Dec 23 21:39:06 ip-172-31-21-195 web: const timeoutError = new error_1.MongoServerSelectionError(`Server selection timed out after ${serverSelectionTimeoutMS} ms`, this.description);
Dec 23 21:39:06 ip-172-31-21-195 web: ^
Dec 23 21:39:06 ip-172-31-21-195 web: MongoServerSelectionError: Server selection timed out after 30000 ms
Dec 23 21:39:06 ip-172-31-21-195 web: at Timeout._onTimeout (/var/app/current/node_modules/mongodb/lib/sdam/topology.js:285:38)
I tried to create a security group allowing incoming connections on port 27017, and tried to attach that to the EC2 instance and to the DocumentDB cluster.
CodePudding user response:
You must ensure you have provided access both directions. Have you read the details from this page: https://docs.aws.amazon.com/documentdb/latest/developerguide/connect-ec2.html?
Have you tried connecting from the instance itself?
mongo --ssl host docdb-2022-02-08-14-15-11.cluster.region.docdb.amazonaws.com:27107 --sslCAFile rds-combined-ca-bundle.pem --username demoUser --password