Failover MongoDB server

Hi,

I am trying to setup rocketchat with multiple databases. I am using version 2.4.11 in a docker container with the following envs:

- MONGO_URL=mongodb://mongo1:27017/rocketchat?replSet=rs01,mongo2:27017/rocketchat?replSet=rs01&readPreference=primaryPreferred&w=majority
- MONGO_OPLOG_URL=mongodb://mongo1:27017/local?replSet=rs01,mongo2:27017/local?replSet=rs01

But I am receiving the following error:
TypeError: Cannot read property ‘indexOf’ of undefined
at parseQueryStringItemValue (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/uri_parser.js:131:20)
at value.split.reduce (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/uri_parser.js:134:26)
at Array.reduce ()
at parseQueryStringItemValue (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/uri_parser.js:132:30)
at parseQueryString (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/uri_parser.js:407:25)
at parseConnectionString (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/uri_parser.js:523:21)
at connect (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/operations/mongo_client_ops.js:195:3)
at connectOp (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/operations/mongo_client_ops.js:284:3)
at executeOperation (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/utils.js:416:24)
at MongoClient.connect (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/mongo_client.js:175:10)
at Function.MongoClient.connect (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/mongo_client.js:341:22)
at new MongoConnection (packages/mongo/mongo_driver.js:177:11)
at new MongoInternals.RemoteCollectionDriver (packages/mongo/remote_collection_driver.js:4:16)
at Object. (packages/mongo/remote_collection_driver.js:38:10)
at Object.defaultRemoteCollectionDriver (packages/underscore.js:784:19)
at new Collection (packages/mongo/collection.js:97:40)
Tried 3 times. Waiting 5 secs…

The databases can see each other:
rs01:SECONDARY> rs.status()
{
“set” : “rs01”,
“date” : ISODate(“2020-04-06T12:25:35.496Z”),
“myState” : 2,
“term” : NumberLong(3),
“syncingTo” : “mongo2:27017”,
“syncSourceHost” : “mongo2:27017”,
“syncSourceId” : 1,
“heartbeatIntervalMillis” : NumberLong(2000),
“optimes” : {
“lastCommittedOpTime” : {
“ts” : Timestamp(1586175928, 1),
“t” : NumberLong(3)
},
“readConcernMajorityOpTime” : {
“ts” : Timestamp(1586175928, 1),
“t” : NumberLong(3)
},
“appliedOpTime” : {
“ts” : Timestamp(1586175928, 1),
“t” : NumberLong(3)
},
“durableOpTime” : {
“ts” : Timestamp(1586175928, 1),
“t” : NumberLong(3)
}
},
“electionParticipantMetrics” : {
“votedForCandidate” : true,
“electionTerm” : NumberLong(3),
“lastVoteDate” : ISODate(“2020-04-06T12:02:17.975Z”),
“electionCandidateMemberId” : 1,
“voteReason” : “”,
“lastAppliedOpTimeAtElection” : {
“ts” : Timestamp(1586174201, 1),
“t” : NumberLong(1)
},
“maxAppliedOpTimeInSet” : {
“ts” : Timestamp(1586174201, 1),
“t” : NumberLong(1)
},
“priorityAtElection” : 1,
“newTermStartDate” : ISODate(“2020-04-06T12:02:17.977Z”),
“newTermAppliedDate” : ISODate(“2020-04-06T12:02:18.766Z”)
},
“members” : [
{
“_id” : 0,
“name” : “mongo1:27017”,
“health” : 1,
“state” : 2,
“stateStr” : “SECONDARY”,
“uptime” : 1413,
“optime” : {
“ts” : Timestamp(1586175928, 1),
“t” : NumberLong(3)
},
“optimeDate” : ISODate(“2020-04-06T12:25:28Z”),
“syncingTo” : “mongo2:27017”,
“syncSourceHost” : “mongo2:27017”,
“syncSourceId” : 1,
“infoMessage” : “”,
“configVersion” : 1,
“self” : true,
“lastHeartbeatMessage” : “”
},
{
“_id” : 1,
“name” : “mongo2:27017”,
“health” : 1,
“state” : 1,
“stateStr” : “PRIMARY”,
“uptime” : 1408,
“optime” : {
“ts” : Timestamp(1586175928, 1),
“t” : NumberLong(3)
},
“optimeDurable” : {
“ts” : Timestamp(1586175928, 1),
“t” : NumberLong(3)
},
“optimeDate” : ISODate(“2020-04-06T12:25:28Z”),
“optimeDurableDate” : ISODate(“2020-04-06T12:25:28Z”),
“lastHeartbeat” : ISODate(“2020-04-06T12:25:35.363Z”),
“lastHeartbeatRecv” : ISODate(“2020-04-06T12:25:34.541Z”),
“pingMs” : NumberLong(0),
“lastHeartbeatMessage” : “”,
“syncingTo” : “”,
“syncSourceHost” : “”,
“syncSourceId” : -1,
“infoMessage” : “”,
“electionTime” : Timestamp(1586174537, 1),
“electionDate” : ISODate(“2020-04-06T12:02:17Z”),
“configVersion” : 1
}
],
“ok” : 1,
“operationTime” : Timestamp(1586175928, 1),
“$clusterTime” : {
“clusterTime” : Timestamp(1586175928, 1),
“signature” : {
“hash” : BinData(0,“AAAAAAAAAAAAAAAAAAAAAAAAAAA=”),
“keyId” : NumberLong(0)
}
}
}

Any help or advice would be appreciated.

Figured it out. It was the way I structured the envs:
- MONGO_URL=mongodb://mongo1:27017,mongo2:27017/rocketchat?replicaSet=rs01&readPreference=primaryPreferred&w=majority
- MONGO_OPLOG_URL=mongodb://mongo1:27017,mongo2:27017/local?replicaSet=rs01