Describe the bug
When using a standard connection string for a MongoDB replica set like mongodb://username:password@hostname-0,hostname-1,hostname-2, the following error message appears in the logs:
"Cannot connect to MongoDB: invalid dsn: error parsing uri: scheme must be \"mongodb\" or \"mongodb+srv\""
To Reproduce
Steps to reproduce the behavior:
Create a secret with such a connection string
Use a secretRef to refer to it
Expected behavior
The connection to MongoDB should succeed.
Logs
"Cannot connect to MongoDB: invalid dsn: error parsing uri: scheme must be \"mongodb\" or \"mongodb+srv\""
Environment
OS: Amazon Linux 2
environment (docker, k8s, etc): EKS 1.29
MongoDB version: 7.0.11
Additional context
The example of a mongodb+srv URI in the documentation is wrong. Such a URI can't have multiple hosts or ports. It uses a DNS SRV record to discover all the members of a replica set. With the mongodb scheme, all the hosts of the replica set should be specified.
Describe the bug When using a standard connection string for a MongoDB replica set like
mongodb://username:password@hostname-0,hostname-1,hostname-2
, the following error message appears in the logs: "Cannot connect to MongoDB: invalid dsn: error parsing uri: scheme must be \"mongodb\" or \"mongodb+srv\"" To Reproduce Steps to reproduce the behavior:secretRef
to refer to itExpected behavior The connection to MongoDB should succeed.
Logs "Cannot connect to MongoDB: invalid dsn: error parsing uri: scheme must be \"mongodb\" or \"mongodb+srv\""
Environment
Additional context The example of a
mongodb+srv
URI in the documentation is wrong. Such a URI can't have multiple hosts or ports. It uses a DNS SRV record to discover all the members of a replica set. With themongodb
scheme, all the hosts of the replica set should be specified.