loopback-connector-mongodb icon indicating copy to clipboard operation
loopback-connector-mongodb copied to clipboard

Unable to connect to Replica Set or Sharded Cluster

Open jukkakilponen opened this issue 3 years ago • 9 comments
trafficstars

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

jukkakilponen avatar Apr 01 '22 12:04 jukkakilponen

@jukkakilponen, thanks for reporting. Would you like to raise a PR?

dhmlau avatar Apr 01 '22 18:04 dhmlau

@dhmlau This bug should have a regression label. Our application is broken since upgrade of mongodb connector to 6.x! There have been security vulnerability fixes in 6.x, which we need but not at the expense of regressed behavior. If no one is looking into, I'll take out some time over weekend to fix this.

jaishirole avatar Apr 08 '22 17:04 jaishirole

@dhmlau @achrinza Can you assign this issue to me? I've coded up a fix, working on unit tests and as soon as done, will raise a PR.

jaishirole avatar Apr 18 '22 11:04 jaishirole

Any updates on this issue since we are also facing the same issue and we are not able to use SRV in our current deployment architecture

manarhusrieh avatar Oct 03 '22 12:10 manarhusrieh

@manarhusrieh My PR has been awaiting merge. @achrinza could you please confirm who would be reviewing and merging the PR?

jaishirole avatar Oct 03 '22 12:10 jaishirole

@jaishirole I think you will need to resolve conflicts in your PR and rebase again on the latest version

manarhusrieh avatar Oct 04 '22 08:10 manarhusrieh

Hi guys, Any update on this issue?

haidanghoang avatar Oct 25 '22 14:10 haidanghoang

I think the PR is close to being merged, but it needs some conflicts resolved by @jaishirole and final approval.

NurdinDev avatar Mar 27 '23 07:03 NurdinDev

It's worth mentioning that 6.1.0 do not have this issue

gian1200 avatar Nov 10 '23 23:11 gian1200