I'm using the node-mongodb-native driver with connect-session-mongo. When I use connect-session-mongo with the Mongos it throws an error in the set method of connect-session-mongo:
[Error: no open connections]
It seems to work just fine if I comment out the connect-session-mongo code. Anyone else using both those together with sharding?
It was fine with replica-set only, but when we setup sharding on a test instance it has been a nightmare.
Any ideas how to get them to play nice? Should I run a second mongos process for each?
Where are you calling db.open? I have a feeling that you're not waiting for db.open to resolve before spinning up your application. You can get around this by calling app.listen inside your db.open callback. Something like the following works for me:
var app = require('express').createServer(),
mongo = require('mongodb'),
db = new mongo.Db('dbname', new mongo.Server('localhost', 27017, { autoreconnect: true })),
MongoSessionStore = require('connect-mongodb');
app.configure(function() {
// ...
app.use(express.session({ secret: "supersecret", store: new MongoSessionStore({url: 'localhost'}) }));
// ...
});
app.get('/', route.index);
// etc...
db.open(function(err){
if(err) throw err;
app.listen(3000);
})
Fixed in Node.JS Mongo Driver update 1.1.5.