question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot connect to a replica set using 5.11.12

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
jooeychengcommented, Feb 3, 2021

@MihaiPerju Can you try appending ?directConnection=true to the Mongo URI?

0reactions
vkarpov15commented, Feb 16, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mongoose connection to replica set not working - Stack Overflow
I am running my own MongoDb Replica Set on Kubernetes. It has 3 members, I exposed them all via NodePort . However, I...
Read more >
Cannot connect to replica set - Replication - MongoDB
I tried following things: Both MongoDB Compass and Robo 3T. In both I tried by entering a connection string with all nodes of...
Read more >
connect failed to replica set - Google Groups
I am running 3.2 version. installed @ C:\Program Files\MongoDB\Server\3.2\bin\mongod.exe in my system. I just tried connecting to replica set through mongo ...
Read more >
How To Configure Keyfile Authentication for MongoDB ...
This tutorial outlines how to update an existing replica set to use keyfile authentication. The procedure involved in this guide will also ...
Read more >
What is the Hyper-V Virtual Switch and how does it work?
It uses single or teamed physical adapters to connect to a physical switch, ... SR-IOV doesn't work in LBFO, but it might with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found