"A timeout occured after 30000ms selecting a server using CompositeServerSelecto..." when trying to query MongoDB

1

I have a windows form application using MongoDB.driver. When I try to query for a user registered in my database I get the followin error:

System.TimeoutException HResult=0x80131505 Message=A timeout occured 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 : "Automatic", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 1, EndPoint : "Unspecified/localhost:27017" }", EndPoint: "Unspecified/localhost:27017", ReasonChanged: "ServerInitialDescription", State: "Disconnected", ServerVersion: , TopologyVersion: , Type: "Unknown", LastHeartbeatTimestamp: null, LastUpdateTimestamp: "2020-08-07T16:47:06.7800654Z" }] }

I'm trying this:

private static IMongoClient client = new MongoClient("mongodb://127.0.0.1:27017/");                            

public static List<T> Select<T>(string collectionName, FilterDefinition<T> filter, int limit = 100) {
    IMongoDatabase db = GetConnection();
    var collection = db.GetCollection<T>(collectionName);
    List<T> result = collection.Find(filter).Limit(limit).ToList();
    return result;
}

public static IMongoDatabase GetConnection() {
    return client.GetDatabase("acquisition");
}

I am able to connect through cmd and if I put a MessageBox.Show() before List result... I'm able to connect to the database with no problems. Anyone ever faced something similar before?

c#
.net
mongodb
asked on Stack Overflow Aug 24, 2020 by Ventricci • edited Aug 26, 2020 by Ventricci

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0