Connecting to Compose.io MongoDB deployment using SSL and mongos through Mongoose.js
Asked Answered
V

1

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.

Veterinarian answered 16/2, 2016 at 18:2 Comment(1)
The Compose.io docs for MongoDB with Mongoose help here.Impart
V
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
  }
}
Veterinarian answered 16/2, 2016 at 18:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.