当我在 C# 中运行我的项目部分时,大约 30 秒内没有任何反应,并在上面的标题中发送该错误消息,我目前正在使用 .NET 5 Framework、最新的 mongo 驱动程序和我自己的 Mongo 主机(我尝试过 Mongo atlas,但它也不起作用)。我不知道为什么这不起作用,想知道是否有人知道原因。
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;
}