Tuesday 11 April 2017

Node.js MongoClient cannot connect to replica set after primary down

With node.js mongodb ver. 2.2.25, I use the following connection string to connect to a replica set with primary node down but failed:

mongodb://user:pass@host1:port1,host2:port2/dbname

However, I can use the same connection string with a PHP mongo client and successfully read data. So is there something wrong with the node.js driver? I also tried adding

?replicaSet=rs1&readPreference=primaryPreferred

to the connection string but also failed.



via konghou

No comments:

Post a Comment