I am connecting to the mongo servers that are not localhost. I am using mongoose. And in some moment I needed to connect with mongo native driver so I am doing it like:
mongoose.mongo.MongoClient.connect(uri, function (err, conn) {});
but conn
object is null
.
Recently I changed servers structure, and now all mongo databases are remote, and on my new node machines I do not have mongo shell installed at all... In first all was working fine and connection uri was:
mongodb://x.x.x.x:27017/database,mongodb://y.y.y.y,mongodb://z.z.z.z
where x.x.x.x:27017
was primary, after some time due the break of the initial primary, new primary has been elected, and now I am starting with the same uri, but connection object is null
and I do not know why...
is there somebody that had similar problem? or maybe solution or idea....
Connection uri was wrong:
instead:
mongodb://x.x.x.x:27017/database,mongodb://y.y.y.y,mongodb://z.z.z.z,{options}
for native driver MongoClient I should used:
mongodb://x.x.x.x:27017,y.y.y.y:27017,z.z.z.z:27017/database?opt1=o1&opt2=o2
this is where I was found this solution: MongoClient.connect