I'm trying to connect to a member of a future replica set in order to initiate the replica set with replSetInitiate
using the official Go mongodb driver (not mgo).
I can connect fine to my instance using the mongodb shell but the same connection string does not work with the go driver. The go driver returns a server selection timeout.
I tried setting the Direct
parameter to true on the client options object but that gives me an unauthenticated error on the first command I try to run. Again, I have no issues with authentication in the mongodb shell, the authentication works properly.
The connection string looks like mongodb://admin:password@host
.
It seems to me like the problem is that the go driver tries to connect to what should be a working replica set, but it hasn't been initialized yet. Is there a way of preventing this behavior of the Go mongodb driver?