node.js - Mongoose hangs forever when replica set is not given -
here's way connect mongodb replica set mongoose:
var connectionstring = 'mongodb://user:password@primary:27017,secondary1:27017,secondary2:27017/dbname?authmecanism=mongodb-cr&replicaset=myset'; var options = { usemongoclient: true }; mongoose.connect(connectionstring, options, error => { if (error) throw error; console.log('database on'); });
if give wrong credentials, connection fail.
if give wrong ips, query end in etimedout.
however if remove replicaset
parameter in connection string, "find" query run forever: won't time out , won't enter callback either.
is there event listen in case?
ps: don't know if relevant i'm using mongo 3.3 mongoose 4.11.
Comments
Post a Comment