1

I wrote a trading app on the example Tradeclient that was on the quickfixn github page. It is now heavily modified, but regarding logging on and off it hasn't been changed. I now have the issue that when the logout button is pressed, it calls the Initiator.Stop, but it doesn't enter into OnLogout as it's supposed to do. When logging on it does everything right, initiator.start and then the OnCreate and then OnLogon, but when logging out, the OnLogout isn't triggered. Any ideas what could be the issue?

    private void Disconnect(object ignored)
    {
        Trace.WriteLine("ConnectionViewModel::Disconnect called");
        _qfapp.Stop();
    }

    public void Stop()
    {
        Trace.WriteLine("QFApp::Stop() called");
        Initiator.Stop(true);
    }

    public void OnLogout(QuickFix.SessionID sessionID)
    {
        // not sure how ActiveSessionID could ever be null, but it happened.
        string a = (this.ActiveSessionID == null) ? "null" : this.ActiveSessionID.ToString();
        Trace.WriteLine(String.Format("==OnLogout: {0}==", a));

        if (LogoutEvent != null)
        {
            LogoutEvent();
        }
    }
MihkelT
  • 131
  • 1
  • 8

1 Answers1

0

It's the same answer as DumbCoder here. The Initiator.Stop(true); stops the initiator engine so all sessions are disconnected. That means there are no more sessions to log out of.

Per this answer you want to first of all logout of the session(s) using

Session.lookupSession(sessionID).logout();

However, per Grant's comment there, that's an unusual thing to do. My guess is that onLogout() functionality is really to capture when client sessions log out of an acceptor, but the acceptor itself stays running. It's not really for the initiator side.

Community
  • 1
  • 1
rupweb
  • 3,052
  • 1
  • 30
  • 57
  • Should you log out first before stopping the initiator engine then? Those code snippets were from the sample trade client, always assumed that it was the right way. – MihkelT Jan 23 '17 at 18:35
  • Well, you never really stop the initiator engine. Notice from the example (https://github.com/connamara/quickfixn/blob/master/Examples/TradeClient/Program.cs#L42) that the initiator code is setup, and then calls the application.Run which is a perpetual `while (true)` so... in the example the `initiator.Stop` is never called unless the application crashes and returns. – rupweb Jan 24 '17 at 17:56