I've had problems connecting to a replica set via the C# sharp driver when using the following code:
var client = new MongoClient("mongodb://daluser:daluatmongo@xxx:25015,yyy:25015,zzz:25015/database?replicaSet=dal_uat_mongo");
var db = client.GetDatabase("database");
var collection = db.GetCollection<BsonDocument>("table");
var foo = collection.CountAsync(document => true).Result;
Here xxx, yyy and zzz are IP addresses and I've used anonymous names for the collection and database.
This results in the following exception: "A timeout occured after 30000ms selecting a server using CompositeServerSelector" (more details in gist link):
https://gist.github.com/bfranklinsportingindex/0270a1e958051b689e56
Strangely if we remove the replica set option and only specify one server then it works fine for two of the three servers. The server that fails gives us the familiar "target machine has refused the connection" error.
I'm currently testing directly with the latest version of the source code and the version of mongo on the server we're tryingt to connect to is 2.6.9
I've tried debugging into the source code for the driver amd I get to the following line in SelectServerAsync method in the Cluster class:
var connectedServers = description.Servers.Where(s => s.State == ServerState.Connected);
Here the connectedServers collection is empty and I would expect (with my limited understanding of driver codebase) it to be populated. Hopefully someone with more experience with this codebase can shed any light on what's going on or provide me with some pointers on where to look in the codebase.