loopbackio / loopbackio/loopback-connector-mongodb
Unable to connect to Replica Set or Sharded Cluster
@jaishirole is already working on this.
Since Apr 18, 2022.
- Dominant language
- JavaScript
- Stars
- 186
- Forks
- 238
- Avg merge
- 2h 49m
- Merged PRs (30d)
- 1
Description
## Steps to reproduce
Have a mongodb connection string with multiple hosts and ports (Replica Set or Sharded Cluster) as in https://www.mongodb.com/docs/manual/reference/connection-string/.
For example mongodb://mongos0.example.com:27017,mongos1.example.com:27017,mongos2.example.com:27017
## Current Behavior
Cannot start the application. TypeError [ERR_INVALID_URL]: Invalid URL: mongodb://mongos0.example.com:27017,mongos1.example.com:27017,mongos2.example.com:27017
## Expected Behavior
Should connect to database.
## Additional information
Tested with 6.2.0.
The problem seems to be the use of nodejs URL to parse the connection string. The URL does not support multiple hosts with port numbers.
See https://github.com/whatwg/url/issues/398.
Problem introduced in commit 1d8a84b.
## Related Issues
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.