In AWS I created a documentdb cluster. I am using the same java program as here with just necessary changes for connection string. here I am not able to connect. Here is the error message:
Feb 06, 2021 9:56:36 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: Cluster created with settings {hosts=[price-manager-prod-new-docdb-clsuter.cluster-
cduzobvhwuhh.us-east-1.docdb.amazonaws.com:27017], mode=MULTIPLE, requiredClusterType=REPLICA_SET,
serverSelectionTimeout='30000 ms', maxWaitQueueSize=500, requiredReplicaSetName='rs0'}
Feb 06, 2021 9:56:36 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: Adding discovered server price-manager-prod-new-docdb-clsuter.cluster-cduzobvhwuhh.us-east-
1.docdb.amazonaws.com:27017 to client view of cluster
Feb 06, 2021 9:56:36 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: No server chosen by com.mongodb.client.internal.MongoClientDelegate$1@5890e879 from cluster
description ClusterDescription{type=REPLICA_SET, connectionMode=MULTIPLE, serverDescriptions=
[ServerDescription{address=price-manager-prod-new-docdb-clsuter.cluster-cduzobvhwuhh.us-east-
1.docdb.amazonaws.com:27017, type=UNKNOWN, state=CONNECTING}]}. Waiting for 30000 ms before timing
out
Feb 06, 2021 9:56:56 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: Exception in monitor thread while connecting to server price-manager-prod-new-docdb-
clsuter.cluster-cduzobvhwuhh.us-east-1.docdb.amazonaws.com:27017
com.mongodb.MongoSocketOpenException: Exception opening socket
at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:70)
at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:128)
at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:117)
Amazon asked to use following connection string. mongodb://docdbnewbie:@price-manager-prod-new-docdb-clsuter.cluster-cduzobvhwuhh.us-east-1.docdb.amazonaws.com:27017/?ssl=true&ssl_ca_certs=rds-combined-ca-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false
In the program, in the connection string I have not used ssl_ca_certs=rds-combined-ca-bundle.pem. The pem file I imported to the keystore. When creating the cluster it asked for a master username & password. I just used docdbnewbie as username & some made-up password.Do I have to create a user beforehand and gave it relevant policy beforehand?
Update: I have been able to establish connectivity between java client & AWS hosted documentdb. But my java program is also in a EC2 - used cloud9. If anybody can throw light on if such connectivity can be establish when the client is outside of VPC that will be of great help.