2

When I run the section of my project in C# nothing happens for about 30 seconds and it sends that error message in the title above, I am currently using .NET 5 Framework, the latest mongo drivers and my own Mongo Host (I tried Mongo atlas and it didnt work either). I have no clue as to why this doesnt work and was wondering if anyone knew why.

MongoClientSettings settings = new MongoClientSettings();
settings.ConnectTimeout = new TimeSpan(1000);
settings.WaitQueueTimeout = new TimeSpan(0, 2, 0);
settings.MinConnectionPoolSize = 1;
settings.MaxConnectionPoolSize = 25;
settings.Server = new MongoServerAddress("139.99.197.10");

Console.WriteLine(" connected");

MongoClient client = new MongoClient(settings);
database = client.GetDatabase(name);
public static bool DoesUserExist(String paramLicense)
{
    List<Profile> records = GetMongo().Load<Profile>("Users");
    bool correctCredentials = false;

    foreach (var record in records)
    {
        if (record.licenseKey.Equals(paramLicense, StringComparison.InvariantCultureIgnoreCase))
        {
            correctCredentials = true;
            break;
        }
    }

    if (correctCredentials) {
        return true;
    }

    return false;
}
EricSchaefer
  • 25,272
  • 21
  • 67
  • 103
AirMarshal
  • 19
  • 2
  • 1
    The error message is rather clear to me. There's a timeout in an operation. Which line has the problem? – PMF Apr 19 '21 at 06:02
  • Please check https://stackoverflow.com/questions/31314245/a-timeout-occured-after-30000ms-selecting-a-server-using-compositeserverselector . It might help. – Sharath N S Apr 19 '21 at 06:07
  • This sounds like a connection timeout - are you certain about your IP address? Maybe you need to specify a port also? Don't you need to specify username/password for that database connection? – Hans Kesting Apr 19 '21 at 07:40
  • @HansKesting by default MonogDB does not use authentication - however it should be the very first option you enable. – Wernfried Domscheit Apr 19 '21 at 08:27
  • @PMF List records = GetMongo().Load("Users") thats the issue, when mongo is called – AirMarshal Apr 22 '21 at 05:34
  • Apparently, the database is unresponsive. Try with some tutorial code or check other answers on the same problem. – PMF Apr 22 '21 at 07:47

0 Answers0