Issue
I need to use an external database in my application, so I created a MongoDB pod using stateful sets. However, I'm not sure if my connection string is formatted correctly. I'm currently using "mongodb://mongod-0.mongodb-service,mongod-1.mongodb-service,mongod-2.mongodb-service:27017/dbname_?" but I'm not sure if it's correct. Can anyone guide me on the correct format for the connection string?
Resolution
The user created a MongoDB pod using stateful sets for an external database. They were using the following connection string: APPSMITH_MONGODB_URI: “mongodb://mongod-0.mongodb-service,mongod-1.mongodb-service,mongod-2.mongodb-service:27017/dbname_?” They wanted to confirm if the syntax was correct.
An expert suggested referring to the official k8s blog post for MongoDB to verify the setup. If the statefulset and headless service have been configured correctly, then the connection string seems correct. However, the user should escape the underscore (_) with a backslash in the connection string. The corrected connection string would be: mongodb://mongod-0.mongodb-service,mongod-1.mongodb-service,mongod-2.mongodb-service:27017/dbname_?