Skip to content

Mongo Connection String with Replica Sets #2446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Vortec4800 opened this issue Aug 3, 2016 · 16 comments
Closed

Mongo Connection String with Replica Sets #2446

Vortec4800 opened this issue Aug 3, 2016 · 16 comments
Labels
type:question Support or code-level question

Comments

@Vortec4800
Copy link
Contributor

Describe your issue in as much detail as possible.

Mongo connection strings with multiple IP addresses don't work.

My mongo string looks like this: mongodb://user:[email protected]:27017,12.12.123.124:27017/dbname

I have a replica set with two replica servers and an arbiter. My parse server is on another box that does not have Mongo installed at all. The two IPs in my connection string point to the two replica servers, so if one goes down the connection string will still work.

This connection string works on Parse.com as expected, but when it's entered in parse-server I get this error:

warn: Unable to ensure uniqueness for usernames: MongoError: no mongos proxies found in seed list

If I change the connection string to look like this: mongodb://user:[email protected]:27017/dbname

It does work.

Steps to reproduce

Please include a detailed list of steps that reproduce the issue. Include curl commands when applicable.

  1. Fresh parse-server install
  2. Point connection string to a replica set with multiple IPs in it
  3. See error

Expected Results

The server will connect to the IPs in order to access the replica set.

Actual Outcome

No connection is made and the error listed above is shown.

Environment Setup

  • Server
    • parse-server version: 2.2.17
    • Operating System: OS X 10.11.6
    • Hardware: MacBook Pro (local development)
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): localhost
  • Database
    • MongoDB version: 3.0
    • Storage engine:
    • Hardware: Digital Ocean (Ubuntu 14.04 LTS 2GB instance)
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): DO

Logs/Trace

You can turn on additional logging by configuring VERBOSE=1 in your environment.

/usr/local/bin/node --debug-brk=57147 --expose-debug-as=v8debug Parse/index.js
Debugger listening on port 57147
parse-server-example running on port 1337.
warn: Unable to ensure uniqueness for usernames:  MongoError: no mongos proxies found in seed list
    at null.<anonymous> (/node_modules/mongodb-core/lib/topologies/mongos.js:304:35)
    at g (events.js:260:16)
    at emitOne (events.js:77:13)
    at emit (events.js:169:7)
    at Object.cb (/node_modules/mongodb-core/lib/topologies/server.js:265:14)
    at /node_modules/mongodb-core/lib/connection/pool.js:443:18
    at authenticateStragglers (/node_modules/mongodb-core/lib/connection/pool.js:399:16)
    at null.messageHandler (/node_modules/mongodb-core/lib/connection/pool.js:421:5)
    at Socket.<anonymous> (/node_modules/mongodb-core/lib/connection/connection.js:294:22)
    at emitOne (events.js:77:13)
warn: Unable to ensure uniqueness for user email addresses:  MongoError: no mongos proxies found in seed list
    at null.<anonymous> (/node_modules/mongodb-core/lib/topologies/mongos.js:304:35)
    at g (events.js:260:16)
    at emitOne (events.js:77:13)
    at emit (events.js:169:7)
    at Object.cb (/node_modules/mongodb-core/lib/topologies/server.js:265:14)
    at /node_modules/mongodb-core/lib/connection/pool.js:443:18
    at authenticateStragglers (/node_modules/mongodb-core/lib/connection/pool.js:399:16)
    at null.messageHandler (/node_modules/mongodb-core/lib/connection/pool.js:421:5)
    at Socket.<anonymous> (/node_modules/mongodb-core/lib/connection/connection.js:294:22)
    at emitOne (events.js:77:13)
@jeacott1
Copy link

jeacott1 commented Aug 4, 2016

"mongodb://user:[email protected]:27017,12.12.123.124:27017/dbname"

you have not specified the ?replset=myreplset url param. so it will never work.

@jeacott1
Copy link

jeacott1 commented Aug 4, 2016

having said that there IS an issue with mongo connections to replicasets.
if parseserver is connected to a replicaset and is IDLE when a mongo election occurs, all is well.
BUT if parseserver is actively chatting to mongo when the election occurs, the client fails to hop to the new master and never recovers until restarted.

@Vortec4800
Copy link
Contributor Author

I was under the impression the replset parameter was optional, as it works properly on Parse.com even when either server is down.

I can try adding that and see if it fixes the issue for me.

@Vortec4800
Copy link
Contributor Author

As an update, I tried updating my connection string to look like this: mongodb://user:[email protected]:27017,12.12.123.124:27017/dbname?replicaSet=rs0 and it made no difference. Still got the same error listed above.

@TylerBrock
Copy link
Contributor

@Vortec4800 please share your rs.config() from the mongo shell and any additional information about your topology, is it possible one of the addresses if for a mongos orthat you started a server with --shardsvr in addition to --replSet?

@Vortec4800
Copy link
Contributor Author

rs0:PRIMARY> rs.config()
{
    "_id" : "rs0",
    "version" : 74799,
    "members" : [
        {
            "_id" : 0,
            "host" : "12.12.123.123:27017",
            "arbiterOnly" : false,
            "buildIndexes" : true,
            "hidden" : false,
            "priority" : 1,
            "tags" : {

            },
            "slaveDelay" : 0,
            "votes" : 1
        },
        {
            "_id" : 1,
            "host" : "12.12.123.124:27017",
            "arbiterOnly" : false,
            "buildIndexes" : true,
            "hidden" : false,
            "priority" : 0.5,
            "tags" : {

            },
            "slaveDelay" : 0,
            "votes" : 1
        },
        {
            "_id" : 2,
            "host" : "12.12.123.125:27017",
            "arbiterOnly" : true,
            "buildIndexes" : true,
            "hidden" : false,
            "priority" : 1,
            "tags" : {

            },
            "slaveDelay" : 0,
            "votes" : 1
        }
    ],
    "settings" : {
        "chainingAllowed" : true,
        "heartbeatTimeoutSecs" : 10,
        "getLastErrorModes" : {

        },
        "getLastErrorDefaults" : {
            "w" : 1,
            "wtimeout" : 0
        }
    }
}

There's my config. I've got 3 boxes, all on Digital Ocean, each running Ubuntu 14.04 x64. I do not have a shard configured.

@TylerBrock
Copy link
Contributor

Maybe it's cause the one node is an arbiter...

@benitech
Copy link

benitech commented Aug 5, 2016

this works:

mongodb://IP1:Port,IP2:Port/DBName?replicaSet=xxxx&w=1&readPreference=nearest&maxPoolSize=50

@lowgator
Copy link

lowgator commented Aug 9, 2016

I recently started to see this today as well for new apps I have been creating. I only get this message when I change the database URL. I even try to restart all the services and I get it as well. I'm on the Azure Parse Managed Instance and it seems that their Parse stack is now Server version: 2.2.17. I see that the issue didn't start until Server version: 2.2.17.

@lowgator
Copy link

lowgator commented Aug 9, 2016

As mentioned before, if you take out all but the primary IP address in the database URI it works. Strange that it was actually working in 2.2.16 with Primary and Secondary String.

@flovilmart
Copy link
Contributor

Running a replicaset With mlab and No issue on my side either

@benitech
Copy link

benitech commented Aug 18, 2016

i can confirm this issue is happening at update from 2.2.16 to 2.2.17

It is throwing similar error as posted.

warn: Unable to ensure uniqueness for user email addresses: MongoError: no primary found in replicaset "at /parse-server/node_modules/mongodb-core/lib/topologies/replset.js:558:32"

@mohitgawande
Copy link

Is it still open or closed as I am getting same problem with parse-server version ~2.2.2

@flovilmart
Copy link
Contributor

@mohitgawande please update to 2.2.18...

@haydenbleasel
Copy link

Still occurring on 2.2.19 (Express 4.14.0, hosting on MLab)

@hramos hramos closed this as completed Nov 29, 2016
@JianxunRao
Copy link

JianxunRao commented Oct 29, 2018

mongodb://root:mypassword@myip_1:3717,myip_2:3717/mydb?replicaSet=mgset-7234487&readPreference=primary&authSource=admin

This URI pattern work for me.

@mtrezza mtrezza added type:question Support or code-level question and removed 🔧 troubleshooting labels Jul 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question Support or code-level question
Projects
None yet
Development

No branches or pull requests