I tried to use MongoDB change streams and i need to use replicaSets but mongoDB doesn't let me use it because of load balancer i tried to set it false like this:
mongodb+srv://${process.env.DB_USERNAME}:${process.env.DB_PASSWORD}@${process.env.DB_CLUSTER}/?replicaSet=rs0&loadBalanced=false&readPreference=secondaryPreferred
but its still giving me same error :
MongoParseError: loadBalanced option not supported with a replicaSet option
Here is my connection code:
const uri = `mongodb+srv://${process.env.DB_USERNAME}:${process.env.DB_PASSWORD}@${process.env.DB_CLUSTER}/?replicaSet=rs0&loadBalanced=false&readPreference=secondaryPreferred`;
const client = new MongoClient(uri, {
useNewUrlParser: true,
useUnifiedTopology: true,
});
await client.connect();
I assume that when you don't configure
loadBalancedat all, you see the same exception. If so, the reason for it is that your server has loadBalanced option configured in txt records. When a driver gets these records after resolving SRV, it implicitly adds them to connection string. IE server/driver expects working in load balancing mode which doesn't support replica set option.nslookupshould help with checking it. I'm not 100% sure, but I think something like this:nslookup -q=TXT yoururl.comshould help to see it