A timeout occured after 30000ms selecting a server while accessing MongoDB in Azure using C#
It's clear that you didn't add the database name inside the connection code.
Here's the template of the connection string
`var client = new MongoClient("mongodb://<dbuser>:<dbuserpassword>@<mongoaddress>/<dbname>?connect=replicaSet&ssl=true&replicaSet=<replicaset>&authSource=<authsource>");var database = client.GetDatabase("test");`
You need to fill the following
- dbuser: user name of the user
- dbuserpassword: password of the database user
- dbname: name of the database
- mongoaddress: address of the mongodb shard
- replicaset: name of the replica set
- authsource: Authentication source
Have you tried adding "?connect=replicaSet" after your connection string :
This JIRA ticket has the details: https://jira.mongodb.org/browse/CSHARP-1160
Effectively, They've made a distinction between connecting to a standalone server and connecting directly to a replica set member, where the latter is relatively uncommon. Unfortunately, MongoLab's Single-Node settings are actually a single node replica set and this causes us to not trust it. You can fix this by appending ?connect=replicaSet to your connection string. It will force the driver to move into replica set mode and all will work.
you can find more details on : https://groups.google.com/forum/#!topic/mongodb-csharp/O460OHiFjZs
Hope it helps.