nodejs/mongoose: connect to db that’s using replica sets

i have installed mongodb (1.8.3) on two seperate servers and set them up to use “replica sets” as found here:

everything looks good so far: one server is recognized as primary, one as secondary (when i access them via commandline).

the problem is that i can’t connect to the DB using node.js
(0.4.10) and mongoose (2.1.0) like this:

var mongo = require('mongoose');

i always get the following error message:

TypeError: Cannot read property 'reconnectWait' of undefined
    at new  (/var/www/node/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connections/repl_set_servers.js:23:31)
    at NativeConnection.doOpenSet (/var/www/node/node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js:80:18)
    at NativeConnection.openSet (/var/www/node/node_modules/mongoose/lib/connection.js:252:8)
    at Mongoose.connectSet (/var/www/node/node_modules/mongoose/lib/index.js:116:27)

searched around a bit and found a post somewhere saying that i also have to supply the name of the replica set – so i tried this instead:

mongo.connectSet('mongodb://host/dbname,mongodb://host2/dbname', rs_name:"name_replicaset"});

what am i doing wrong here …?!

Problem courtesy of: Philipp Kyeck

稿源:Node.js Recipes - The solution to all Node problems (源链) | 关于 | 阅读提示

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 前端开发 » nodejs/mongoose: connect to db that’s using replica sets

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录