I have 3 AWS EC2 instances. 2 for mongodb replica and 1 as my server. I have followed this article to set up my replica set but there is no information on how to connect my nodejs server using mongoose.
I searched and got this as results
mongoose.connect('mongodb://replica1.example.com:27017,replica2.example.com:27017,replica3.example.com:27017/mydatabase?ssl=true', {
sslValidate: true,
sslCA: fs.readFileSync('/path/to/ca.pem'),
sslKey: fs.readFileSync('/path/to/client.pem'),
sslCert: fs.readFileSync('/path/to/client.pem')
});
As per the article I have different sslKey and Cert for my replica member host 1 and replica member host 2
I am unable to connect to the database as it gives this as error
Could not connect to database: MongoNetworkError: failed to connect to server [replica2.example.com:27017] on first connect [Error: getaddrinfo ENOTFOUND replica2.example.com
I believe this is because I did not specify the ssl key for 2nd member. But how can I do that?