Creating a MongoDB Replica Set Service

I’m trying to create a Service using a MongoDB Replica Set. MongoDB’s docs says here that the connection string format has to be

mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]

So, my connection string is something like

mongodb://IP1:PORT1,IP2:PORT2,IP3:PORT3/DATABASE?replicaSet=REPLICA_SET_NAME

But when I try to explore the service, I’m not getting any data, collection or schema and I noticed that DreamFactory created another database called “DATABASE?replicaSet=REPLICA_SET_NAME”. I tried to just remove these options “replicaSet=REPLICA_SET_NAME” to see what happens and then I’m getting this error while I explore:

{
  "error": [
    {
      "context": null,
      "message": "Failed to list resources for this service.\nIP1:PORT1: not master and slaveOk=false",
      "code": 500
    }
  ]
}

If I keep trying to explore the same REST Endpoint (for instance, /rest/API-NAME?names_only=true&include_schemas=true), then I eventually get the correct response. It seems that it tries with a different ip and port every time I make the request.

I also noticed that if I just leave the primary server and remove the options from the connection string, then it works fine. But this is pointless, because I’m losing the whole replica set point.

I even tried to set a lookup key with the name “replicaSet” equals to REPLICA_SET_NAME, but it didn’t work either.

How can I use MongoDB replica sets with DreamFactory?

We have a replicaSet connection set up here, but are unsure how to confirm it’s properly implementing replication. In our case, we have the first host in the connection string. E.g., if the URI is

mongodb://user:password@domainone.com:27017,domaintwo.com:27017/mongo?replicaSet=set-name

then the connection string in DSP is

mongodb://domainone.com:27017

This works for us and does not cause an error.