简体   繁体   English

SeqReset后注销无法正常工作

[英]logout not working after SeqReset

Using C# and QuickFix/N 使用C#和QuickFix / N

I am trying to logout cleanly from an initiator. 我正在尝试从启动器干净地注销。

           initiator.Stop(true);

            int tryCount = 5;
            while (initiator.IsLoggedOn)
            {
                tryCount--;
                if (tryCount <= 0)
                    break;
                Thread.Sleep(1000);
            }

If I previously logged out cleanly - by which I mean I sent and received 35=5 messages. 如果我以前干净地注销了-我的意思是说我发送和接收了35 = 5条消息。 Then the logout works. 然后注销就可以了。

However, if I just cut the connection and on login I get 35=4 messages aslking for a reset, then when I try to logout I don't see my own 35=5 in the logs. 但是,如果我只是断开连接并在登录时得到了35 = 4条消息以进行重置,那么当我尝试注销时,在日志中看不到自己的35 = 5。

Why? 为什么?

I also got this message at logout on one occasion: 我也有一次在注销时收到此消息:

System.ObjectDisposedException was unhandled HResult=-2146232798 未处理System.ObjectDisposedException HResult = -2146232798
Message=Cannot access a disposed object. Message =无法访问已处置的对象。 Object name: 'FileLog'. 对象名称:“ FileLog”。
Source=QuickFix ObjectName=FileLog StackTrace: at QuickFix.FileLog.DisposedCheck() at QuickFix.FileLog.OnEvent(String s) at QuickFix.Session.Disconnect(String reason) at QuickFix.SocketInitiatorThread.Read() at QuickFix.Transport.SocketInitiator.SocketInitiatorThreadStart(Object socketInitiatorThread) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart(Object obj) InnerException: Source = QuickFix ObjectName = FileLog StackTrace:位于QuickFix.FileLog.DisposedCheck()位于QuickFix.FileLog.OnEvent(String)位于QuickFix.Session.Disconnect(String reason)位于QuickFix.SocketInitiatorThread.Read()在QuickFix.Transport.SocketInitiator System.Threading.ExecutionContext.RunInternal(ExecutionContextexecutionContext,ContextCallback回调,对象状态,布尔值保持同步Ctx)在System.Threading.ExecutionContext.Run(ExecutionContext执行上下文,ContextCallback回调,对象状态,布尔值在系统时System.Threading.ThreadHelper.ThreadStart(Object obj)处的.Threading.ExecutionContext.Run(ExecutionContext执行上下文,ContextCallback回调,对象状态)InnerException:

EDIT 编辑

I have found a solution, which is to log out each session before calling Stop. 我找到了一个解决方案,那就是在调用Stop之前注销每个会话。 This is NOT suggested in the documentation. 文档中不建议这样做。

I thought Stop would implicitly do this. 我以为Stop会隐式地这样做。

            var sessionIDs = initiator.GetSessionIDs().ToList();
            foreach (var sessionID in sessionIDs)
            {
                Session session = Session.LookupSession(sessionID);
                session.Logout("Normal logout");

            }
            Thread.Sleep(1000);
            int tryCount = 5;
            while (initiator.IsLoggedOn)
            {
                tryCount--;
                if (tryCount <= 0)
                    break;
                Thread.Sleep(1000);
            }
            initiator.Stop(true);

initiator.Stop(true); Initiator.Stop(true);

Your initiator has stopped, all sessions terminated, so which session are you logging out of ? 您的发起方已停止,所有会话已终止,因此您要注销哪个会话?

You log out of all sessions cleanly, log off and then stop the initiator. 您可以干净地注销所有会话,然后注销然后停止启动程序。 Supposedly one session was still receiving any messages and you stop the initiator without logging them off, your counterparty will try again to send the message, assuming you have crashed. 假设一个会话仍在接收任何消息,并且您停止了启动程序但未注销它们,那么您的交易对手将再次尝试发送消息(假设您已崩溃)。 If you log them out, they will realize the session has been terminated and try logging in before sending a message. 如果您注销它们,他们将意识到会话已终止,并在发送消息之前尝试登录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM