mongo-js/mongojs

Using replicaSet and readPreference option

alicehelen opened this issue · 1 comments

We were using mongojs version 0.18.2 and node version 4.4.0 and the connection string we used was
mongodb://dbName:userId@a:27018,b:27018,c:27018/dbName?readPreference=secondaryPreferred&maxStalenessSeconds=120

The connection was successful and all the writes were going to primary server a:27018 and reads were going to secondary servers b:27018 and c:27018.

Now when we upgraded the node version to 10.15, we also upgraded the mongojs to latest version 2.6.0. When we tried to use the same connection string, it gave error that replicaSet option is mandatory. So we modified the connection string to use replicaSet like
mongodb://dbName:userId@a:27018,b:27018,c:27018/dbName?readPreference=secondaryPreferred&maxStalenessSeconds=120&replicaSet=qa

With the new connection string, all the reads and writes are going to primary server and there are no read calls to secondary server even though the readPreference=secondaryPreferred option is present. Can you please check this issue?

Note: If we change the readPreference to secondary instead of secondaryPreferred, then we get cursor error wireProtocolHandler is null

Can anyone please help to look into this issue?