MongoDB: A timeout occured after 30000ms selecting a server using CompositeServerSelector
<p>I'm completely stumped.  I am using the latest c# drivers (2.3.0.157) and the latest MongoDB (3.2).  The DB is running as a standalone setup with no replication or sharding.  I've tried running locally on Windows as well as remotely on Amazon LINUX.  </p>

<p>I continue to get a timeout error but mysteriously sometimes it just works (maybe once every 20 - 30 attempts).</p>

<p>I am creating the connection as such:</p>

<pre><code>private static readonly string ConnectionString = ConfigurationManager.ConnectionStrings["MongoDB"].ToString();
private static readonly string DataBase = ConfigurationManager.ConnectionStrings["MongoDBDatabase"].ToString();

private static IMongoDatabase _database;


public static IMongoDatabase GetDatabase(string database)
{
    if (_database == null)
    {
        var client = new MongoClient(ConnectionString);
        _database = client.GetDatabase(database);

    }

    return _database;
}
</code></pre>

<p>And calling it like this:</p>

<pre><code>public static List&lt;Earnings&gt; GetEarnings()
{
    var db = GetDatabase(DataBase);
    if (db == null) return new List&lt;Earnings&gt;();
    var logs = db.GetCollection&lt;Earnings&gt;("EarningsData");
    var all = logs.Find(new BsonDocument()).ToEnumerable().OrderBy(x =&gt; x.Symbol).ToList();
    return all;
}
</code></pre>

<p>And it'll time out on the logs.Find part of the method.  Here's the full message:</p>

<p>Additional information:</p>

<blockquote>
  <p>A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = ReadPreferenceServerSelector{ ReadPreference = { Mode = Primary, TagSets = [] } }, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 } }. Client view of cluster state is { ClusterId : "1", ConnectionMode : "Direct", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 1, EndPoint : "XX.XX.XX.XX:27017" }", EndPoint: "XX.XX.XX.XX:27017", State: "Disconnected", Type: "Unknown" }] }.</p>
</blockquote>

<p>I've tried using the fully qualified host name, adding connect=direct and connect=replicaSet to the connection string, using MongoClientSettings instead of the connection string and everything else I could possibly find on forums and StackOverflow.  I'm at a loss and not even sure where to look next.  Any advice?</p>

<p>I should also add, I can connect fine from the command line and RoboMongo...</p>