HI
I want to ask how I solve this problem.
currently I run mongoDB on AWS (EC2) and I configured replica set
(which means I have 3 instances, primary, secondary, abiter, actually the configuration was successful
let me describe our AWS architecture
We have a Bastion instance on public that facing global internet(just for ssh tunneling)
and as I mentioned We have 3 EC2 instances what running mongoDB replica on private subnet
so, when I tried to connect from local(which means from global) I have to go to Bastion instance first and then connect to private MongoDB instance
but, "No replica set members found yet, Timeout: 10.0s, Topology Description: <TopologyDescription id: 6333aa0a4f0ddb9c168e0143, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription (‘10.1.3.108’, 27017) server_type: Unknown, rtt: None>, <ServerDescription (‘10.1.3.43’, 27017) server_type: Unknown, rtt: None>, <ServerDescription (‘10.1.3.49’, 27017) server_type: Unknown, rtt: None>]>
"
this error message came out first
because I connected to mongoDB by using nginx reverse proxy
In Bastion that facing public,
/etc/nginx/nginx.conf
stream {
server {
listen 27018;
proxy_pass 10.1.3.108:27017;
}
}
I add this to redirect to actual mongoDB instance(primary)
and then In applicaton
self.client = MongoClient(
host=Bastion's public IP,
port=27018,
username=settings.MONGO_USERNAME,
password=settings.MONGO_PASSWORD,
authSource=settings.MONGO_AUTH_SOURCE,
authMechanism=settings.MONGO_AUTH_MECHANISM,
serverSelectionTimeoutMS=10000
)
at the log I found It reached successfuly first,
I think after first touch, the primary mongodb instance return replica member’s name which I configured first to client
after first touch client tried to connect private IP, but cilent couldn’t reach to private IP
that’s why this situation happened I guess
and then I tried to connect via ssh tunneling In python app
self.client = MongoSession(
host=Bastion's public IP,
port=22,
user='ec2-user',
key=key_path,
to_port=27017,
to_host='10.1.3.108'
)
but this time It didn’t find internal host ‘10.1.3.108’
10.1.3.108:56424: timed out, Timeout: 30s, Topology Description: <TopologyDescription id: 6333c051c87d04dc997fdc49, topology_type: Unknown, servers: [<ServerDescription ('10.1.3.108', 56424) server_type: Unknown, rtt: None, error=NetworkTimeout('10.1.3.108:56424: timed out')>]>
actually It doesn’t affect to actual service operation,
this problem makes coworker couldn’t test on local.
I know our test environment sucks
But I can’t help
plz give me solution
thanks
P.S It didn’t any happen when we use mongoDB standalone