Cannot connect to a replica set using 5.11.12
See original GitHub issueI am running my own MongoDb Replica Set on Kubernetes.
It has 3 members, I exposed them all via NodePort.
I can connect to it via shell:
(feel free to connect, it’s an empty, isolated example that will be destroyed)
mongo mongodb://stackoverflow:practice@134.122.99.184:31064,134.122.99.184:31086,134.122.99.184:32754/thirty3?authSource=admin
However, I cannot connect to it via mongoose 5.11.12 using the same connection string. It only works until mongoose 4.5.8
mongoose.connect("mongodb://stackoverflow:practice@134.122.99.184:31064,134.122.99.184:31086,134.122.99.184:32754/thirty3?authSource=admin&replicaSet=thirty3&?retryWrites=true&w=majority",
{
useNewUrlParser: true,
poolSize: 5,
useUnifiedTopology: true,
serverSelectionTimeoutMS: 5000, // Timeout after 5s instead of 30s
})
I tried tons of configurations, gssapiServiceName=mongodb
, replicaSetName=thirty3
(I checked the replica set name by running rs.conf()
) and many more other configurations.
My question is - is there something wrong with mongoose handling these types of communications?
I have found similar issues that indicate downgrading as a solution, but downgrading is not ideal unless impossible to fix it normally.
Please try the code samples above, the database is open for connections with the credentials exposed.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
@MihaiPerju Can you try appending
?directConnection=true
to the Mongo URI?I’m going to close this one since it looks like the servers are no longer available. As far as I can tell, this is an issue with replica set host names, you need to make sure that the host names in
rs.conf()
are the same ones as the ones in your connection string.