Connection String for Azure Cosmos DB API for Mongo DB

We are tyring to create a data source in Stardog Studio to connect to our Azure Cosmos DB with MongoDB API using MongoDB driver provided by Stardog. But getting Read time out error. Following exception is logged in log file:

WARN 2021-11-02 14:07:46,946 [stardog-user-69] com.complexible.stardog.protocols.http.server.StardogUndertowErrorHandler:accept(68): Unexpected exception was handled by the server
com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address:10255=XXX.mongo.cosmos.azure.com, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketReadTimeoutException: Timeout while receiving message}, caused by {java.net.SocketTimeoutException: Read timed out}}]

We are using following uri to connect : mongodb://XXX.mongo.cosmos.azure.com:10255/mydb
also setting the username and password as jdbc.username and jdbc.password variables.

We also tried to connect using following uri, but getting same error
mongodb+srv://myUserName:myP4ssw0rd@XXX.mongo.cosmos.azure.com/mydb

So would like to know what should be the connection string for Azure Cosmos DB API for Mongo DB and how to specify the port as the port is 10255.

Thanks!

Using connection string in following format solved our issue:
mongodb: //username:password@host:port/database?ssl=true

Thanks!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.