using the URI I can connect to my MongoDB through Studio3T but when I use this URI in my Node app through Mongoose it never connects, nor gives any error.
Following are the Screenshots for rs.status() output displaying details of member member data from rs.status
It’s been a while since you posted this question. Are you still having issues with connecting using Mongoose?
If yes, what if you try to connect using a simple node script, e.g:
const MongoClient = require('mongodb').MongoClient;
let run = async function() {
console.log('start')
let opt = {poolSize:1, useNewUrlParser: true, useUnifiedTopology: true}
let conn = await MongoClient.connect(
'mongodb://username:password@127.0.0.1:27017/test?authSource=admin&replicaSet=rs0',
opt)
console.log('db connected')
console.log(await conn.db('test').collection('test').findOne())
conn.close()
console.log('db closed')
}().catch(console.error)
The snippet above should try to connect to the database test, then print a single document from the collection test. If this snippet works, then we need to look deeper into why Mongoose have issues.