I have a NodeJS app in which I need to connect to to MongoDB databases - one a single server set up, and the second from a replica set. I connect to the next one just fine, but when connecting to the second one - I get the following error:
/Users/iddogino/Documents/RapidApp/node_modules/mongodb/lib/mongodb/db.js:299
throw err;
^
TypeError: Cannot set property 'auto_reconnect' of undefined
at /Users/iddogino/Documents/RapidApp/node_modules/mongodb/lib/mongodb/connection/repl_set/options.js:110:35
at Array.forEach (native)
at Options.decorateAndClean (/Users/iddogino/Documents/RapidApp/node_modules/mongodb/lib/mongodb/connection/repl_set/options.js:108:16)
at new exports.ReplSet (/Users/iddogino/Documents/RapidApp/node_modules/mongodb/lib/mongodb/connection/repl_set/repl_set.js:84:31)
at /Users/iddogino/Documents/RapidApp/node_modules/mongodb/lib/mongodb/mongo_client.js:320:30
at /Users/iddogino/Documents/RapidApp/node_modules/mongodb/lib/mongodb/db.js:296:11
at process._tickDomainCallback (node.js:459:13)
The code I use to connect (after omitting user names and real urls) is:
require('mongodb').MongoClient.connect("mongodb://password@url1:port1,url2:port2/dbName?replicaSet=setName&w=0&readPreference=secondary", function(err, doc) {...});
Now when I tried this alone (not after the code connecting to true other DB), I worked just fine... Any ideas?