5

I'm using compose.io for hosting test and production mongodb databases and am attempting to connect through a node app using mongoose.js (which uses the standard nodejs mongodb driver under the hood). My connection options are as follows:

var connectionString = 'mongodb://user:password@host1:port1,host2:port2/dbname?ssl=true';

var options = {
  mongos: true,
  server: {
    ssl: true,
    sslValidate: true,
    sslCA: [fs.readFileSync('/path/to/cert/certificate.pem')] // cert from compose.io dashboard
  }
}

mongoose.createConnection(connectionString, options);

The connection just seems to hang, though. I don't receive an error from the server, nor do I receive an 'open' event.

chas
  • 407
  • 4
  • 6
  • The [Compose.io docs for MongoDB with Mongoose](https://help.compose.io/docs/connecting-to-mongodb#section-connecting-with-mongoose-javascript-) help here. – Dr G. May 13 '16 at 04:55

1 Answers1

9

ANSWER

I was able to fix the issue by moving all of the options from server into mongos:

var options = {
  mongos: {
    ssl: true,
    sslValidate: true,
    sslCA: [fs.readFileSync('/path/to/cert/certificate.pem')] // cert from compose.io dashboard
  }
}
chas
  • 407
  • 4
  • 6