I try to connect from C# function in POD, deployed on Azure, to Mongo DB Atlas free tier M0 cluster and receive Timeout exception as:
System.TimeoutException: A timeout occurred after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 } }. Client view of cluster state is { ClusterId : “1”, ConnectionMode : “ReplicaSet”, Type : “ReplicaSet”, State : “Disconnected”, Servers : }.
I am using the latest Mongo DB Driver 2.12.2 and here is the format of connection strings:
mongodb+srv://username:password@cluster.xxxx.mongodb.net/dbname?authSource=admin&replicaSet=atlas-jwdysc-shard-0&readPreference=primary&ssl=true
or
mongodb+srv://username:password@cluster.xxxx.mongodb.net/dbname?retryWrites=true&w=majority
Network access in Atlas set to all (IP Access List Entry: 0.0.0.0/0)
From local workstation the connection is success from any application (POD, UniTest, Compass).
From Mongo DB shell on Azure POD the connection is success too.
From POD in Azure connection success when I use connection string:
mongodb://username:password@cluster-shard-00-00.xxxx.mongodb.net:27017,cluster-shard-00-01.xxxx.mongodb.net:27017,cluster-shard-00-02.xxxx.mongodb.net:27017/dbname?ssl=true&replicaSet=atlas-jwdysc-shard-0&authSource=admin&retryWrites=true&w=majority
Questions:
-
Why application with Mongo DB Driver 2.12.2 could not connect to Atlas from Azure with connection string dedicated to driver version 2.11 and later and should use connection string dedicated to version 2.4?
-
How can I config my application to use the standard connection string on Azure?