在我们的群集上执行故障转移时,在应用程序成功使用新选择的主数据库之前,每次(但仅一次)抛出以下EndOfStreamException
。
我正在使用2.5.0的.NET驱动程序,并在连接字符串中提供副本集名称:
var url = MongoUrl.Create("mongodb://<dbuser>:<dbpassword>@ds012345-a0.mlab.com:56789,ds012345-a1.mlab.com:56790/<dbname>?replicaSet=rs-ds012345");
var client = new MongoClient(new MongoClientSettings()
{
Servers = url.Servers,
Credentials = credentials
});
MongoDB.Driver.MongoConnectionException:发生异常时 从服务器接收消息。 ---&GT; System.IO.EndOfStreamException:尝试读取过去的结尾 流。在 MongoDB.Driver.Core.Misc.StreamExtensionMethods.d__2.MoveNext() ---从抛出异常的先前位置开始的堆栈跟踪结束--- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务) MongoDB.Driver.Core.Connections.BinaryConnection.d__51.MoveNext() ---内部异常堆栈跟踪结束---在MongoDB.Driver.Core.Connections.BinaryConnection.d__51.MoveNext() ---从抛出异常的先前位置开始的堆栈跟踪结束--- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务) MongoDB.Driver.Core.Connections.BinaryConnection.d__52.MoveNext() ---从抛出异常的先前位置开始的堆栈跟踪结束--- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务) MongoDB.Driver.Core.Connections.BinaryConnection.d__54.MoveNext() ---从抛出异常的先前位置开始的堆栈跟踪结束--- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务) MongoDB.Driver.Core.WireProtocol.CommandWireProtocol
1.<ExecuteAsync>d__11.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at MongoDB.Driver.Core.Servers.Server.ServerChannel.<ExecuteProtocolAsync>d__26
1.MoveNext() ---从抛出异常的先前位置开始的堆栈跟踪结束--- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务) MongoDB.Driver.Core.Operations.CommandOperationBase1.<ExecuteProtocolAsync>d__29.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at MongoDB.Driver.Core.Operations.ReadCommandOperation
1.d__2.MoveNext() ---从抛出异常的先前位置开始的堆栈跟踪结束--- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务) MongoDB.Driver.Core.Operations.FindCommandOperation1.<ExecuteAsync>d__111.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at MongoDB.Driver.Core.Operations.FindOperation
1.d__111.MoveNext() ---从抛出异常的先前位置开始的堆栈跟踪结束--- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务) MongoDB.Driver.OperationExecutor.d__11.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at MongoDB.Driver.MongoCollectionImpl
{1.d__60 {1}} 1.MoveNext() ---从抛出异常的先前位置开始的堆栈跟踪结束--- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务)
答案 0 :(得分:0)
我也面临着同样的错误,但是又来了。一旦请求成功,第二次失败,就会出现上述错误。
为解决此问题,我使用了如下的 prev.Cost === curr.Cost && prev.Count > curr.Count || prev.Cost < curr.Cost
? prev
: curr
((prev.Cost - curr.Cost) || (prev.Count - curr.Count)) < 0
? curr
: prev
请检查是否也可以解决您的问题。 谢谢