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.

Update DB URI Parsing from CLI Params to Allow mongoDB+srv protocol

See original GitHub issue

I am deploying a Mongo instance using Mongo Atlas. In one of the newer driver versions, a new protocol was added to allow connecting to a Mongo cluster without having to specify all hosts in the cluster. Details may be found in the MongoDB 3.6 docs. The mongo-seeding-cli works fine with the new protocol if the user specifies the connection address using a DB URI string. However, the user is unable to specify individual parameters using the new service because the core mongo seeding library automatically adds a port to the connection string, which is not allowed when connecting to mongo using the mongo+srv protocol.

mongo-seeding Connecting to mongodb+srv://<myAdmin>:<myPassword>@runewordfinder-0ltsc.mongodb.net:27017/runewordfinder... +9ms
(node:73572) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
  mongo-seeding Ports not accepted with `mongodb+srv` URIs

I would like to be able to specify the individual parameters so I may hide my password as an environment variable. I propose that core/src/database/database-connector.ts#getDbConnectionUri(...) is updated to check the provided protocol and create an appropriate string that:

  • Includes the port if protocol === 'mongodb'
  • Does not include the port if protocol === 'mongodb+srv'

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

0reactions
pkosieccommented, May 6, 2019

@BenedictRasmussen Sure thing - I’m going to update dependencies and then I will publish new release 🙂It should arrive in next 2 hours.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Connection String URI Format — MongoDB Manual
This section describes the standard format of the MongoDB connection URI used to connect to a MongoDB deployment: standalone, replica set, ...
Read more >
Here to SRV you with easier replica set connections | MongoDB
We can run this script using the node specified in the 3.6 connection string as a parameter. The node is specified in the...
Read more >
Unable to connect with node.js due to "mongodb+srv"
js parsing issue, specifically related to the “mongodb+srv”. (If I remove the + it gets past the error, but then of course doesn't...
Read more >
Invalid URI scheme: mongodb+srv - Drivers & ODMs
Hi, I am trying to connect my python application. Every time I am getting Invalid URI scheme: mongodb+srv error while trying to connect...
Read more >
MongoDB Server Parameters
Available for both mongod and mongos . Specifies the list of authentication mechanisms the server accepts. Set this to one or more of...
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