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:
mongodb://seconday.server:27017/dbname?slaveOk=true
mongodb://seconday.server:27017/dbname?readPreference=secondary
mongodb://primary.server:27017,seconday.server:27017/dbname?replicaSet=myset&readPreference=secondary
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:
Meteor: 1.5.2.2
MongoDB: 3.4 (both primary and secondary)
Pointing me to the right direction would be a big help.
Hi @jadus do you have a problem with this? I connect in multiple platforms to multiple Mongo (Atlas) and in all I “cross connect”. DBs. You can connect into as many DBs as you want in 2 concepts:
initiate connection and remain connected (normal Meteor behavior).
open connection, do transaction, close connection.
Let me know if I can assist in any way.
Hi @paulishca, thanks for your help. A Mongodb consultant told me to add “readPreference=secondary” to my mongo connexion string (settings.json galaxy.meteor.com env MONGO_URL) in order to improve performance but I wanted to be sure that meteor can handle this
If you update a lot of data and looking to millisecond performance, primaryPreferred with hedged reads might yield more precise query responses.
With .rawCollection you can use all Mongo official options.