loopbackio / loopbackio/loopback-connector-mongodb

Unable to connect to Replica Set or Sharded Cluster

Open
#663 9 comments 3 reactions 1 assignee View on GitHub

@jaishirole is already working on this.

Since Apr 18, 2022.

bug v6.x
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.