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.

deno_mongo uses replica information from primary instead of URL

See original GitHub issue

We have a replica set on MongoDB configured with hosts set in the /etc/hosts file which don’t exist on our development machines. When using a URL with the actual domains that are public, deno_mongo uses the information from the primary server instead of the URL. This is not the behaviour we get with Node’s MongoDB or with MongoDB Compass (which both use the servers in the connection URL).

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Error { kind: ServerSelectionError { message: "Server selection timeout: No available servers. Topology: { Type: ReplicaSetNoPrimary, Servers: [ { Address: premid:27017, Type: Unknown, Error: The supplied Host is unknown. (os error 11001) }, { Address: premid2:27017, Type: Unknown, Error: The supplied Host is  (os error 11001) }, { Address: premid3:27017, Type: Unknown, Error: The supplied Host is (os error 11001) }, ] }" } }', src\command\find.rs:41:26

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
Timeraacommented, Jun 12, 2020

Until this issue is fixed, use this as a temporary solution (Windows only):

  1. Open C:\Windows\System32\drivers\etc\hosts in a text editor of your choice
  2. Add your hosts at the bottom of the file like this:
IP HOST
IP HOST2
IP HOST3
  1. Save the file, run ipconfig /flushdns in a terminal
  2. Try again, if it doesn’t work try restarting the terminal
  3. Enjoy!
0reactions
lucarduccicommented, Jun 28, 2020

I have the same problem also without replica. Is it possible to set the “moongose” option { useUnifiedTopology: true } in the connection?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Replica Set Primary — MongoDB Manual
The primary is the only member in the replica set that receives write operations. ... Then the secondaries replicate the oplog to apply...
Read more >
MongoDB Connection String to Replica Set - Stack Overflow
In my experience, the problem isn't when "the primary goes down or is very busy" that is the problem with just specifying the...
Read more >
MongoDB Replica Set: 3 Easy Methods to Replicate Data
A complete walkthrough of the content will help you develop the skill to set up MongoDB Replica Sets using various methods.
Read more >
Shouldn't mongoose detect primary in a replica set? #2089
I'm using a replica set with one primary and one secondary (hosted by MongoHQ) and connecting using mongoose.connect('mongodb://user:pass@hello.com:12345/my_db, ...
Read more >
mongo@v0.31.1 - Deno
... mechanism: "SCRAM-SHA-1", }, }); // Connect using srv url await client.connect( ... atlas_sdk TypeSafe MongoDB Atlas Data API SDK for Deno &...
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