Connect to a secondary mongodb server for reading



Anyone ever tried connecting to a secondary mongodb server using MongoInternals.RemoteCollectionDriver and do some reads? I’ve tried different connection strings and options but still I’m unable to make it work. I’ve dug deep through meteor code and seems url and options are being passed correctly to mongo driver. Not sure where the issue is.

Here’s a few connection strings I’ve tried:

Also tried passing options to MongoInternals.RemoteCollectionDriver:
{ readPreference: “secondary”}
{ readPreference: “secondary”, slaveOk: true}
{ db: {readPreference: “secondary”}}

I’ve also tried combinations of both but still didn’t.

Error I’ve got for the connection string with replicaSet:
MongoError: no connection available

Errors for the rest is usually:
MongoError: not master and slaveOk=false

I’m using versions below:
MongoDB: 3.4 (both primary and secondary)

Pointing me to the right direction would be a big help.



Hi @ianfynd,

I’m trying the same thing and finding the same issues as you.
Did you ever manage to make it work? Or find a workaround?

Thank you


@nelsonuruworks unfortunately no. I ended up connecting directly to the primary. Please let me know if you find a solution.


There isn’t anything theoretically wrong with connecting to a secondary when you specify a readpreference and have the list of hosts.

The bug is probably