我在尝试使用MongoDB获取玩家数据时遇到了未知和意外错误?我是mongo的新手,所以我想知道是否有人可以提供帮助。
System.TimeoutException: 'A timeout occured after 3000ms 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 : "127.0.0.1:3306" }", EndPoint: "127.0.0.1:3306", State: "Disconnected", Type: "Unknown", HeartbeatException: "System.InvalidOperationException: Invalid BinaryConnection state transition from 4 to Failed.
at MongoDB.Driver.Core.Connections.BinaryConnection.OpenConnectionHelper.FailedOpeningConnection(Exception wrappedException)
at MongoDB.Driver.Core.Connections.BinaryConnection.<OpenHelperAsync>d__48.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at MongoDB.Driver.Core.Servers.ServerMonitor.<HeartbeatAsync>d__27.MoveNext()" }] }.'
C#:
if (HasAuthenticated)
{
return;
}
var database = Program.Server.DatabaseHandler.MongoDatabase;
var collection = database.GetCollection<User>("habbo_users");
var playerData = collection.Find(x => x.AuthTicket == authTicket).Limit(1).First();
if (playerData == null)
{
throw new Exception("Couldn't find players data using this auth ticket.");
}
Console.WriteLine(playerData.Username + " logged in with " + playerData.AuthTicket + " and ID: " + playerData.Id);
如果把它抛到这一行
var playerData = collection.Find(x => x.AuthTicket == authTicket).Limit(1).First();
答案 0 :(得分:0)
此部分描述了异常的实际来源:
HeartbeatException:“ System.InvalidOperationException:无效 BinaryConnection状态从4转换为Failed。 ...
这是MongoDB.Driver.Core
及更低版本的2.7.0
的错误,但仅隐藏了其他一些异常。检查您的MongoDB.Driver.Core
版本。如果它低于2.7.1
,则将其更新到此版本或更高版本。它不能解决您的问题,但是您将隐藏实际的异常。
实际的异常将在同一位置:... HeartbeatException: [exception text here]
。
如果您需要更多相关信息,可以访问issue itself。