rupweb
rupweb

Reputation: 3328

QuickFixN has session disconnection event that doesn't call OnLogout

In the QF event log there are session layer events:

20180418-13:30:51.268 : Connection failed: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond #.#.#.#:#
20180418-13:31:00.288 : Connecting to #.#.#.# on port #
20180418-13:31:21.293 : Connection failed: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond #.#.#.#:#
20180418-13:31:00.288 : Connecting to #.#.#.# on port #

What's the event handler to use to report / react to these events? The OnLogout handler is not being called.

I don't want to use FromEarlyIntercept that I guess would catch the event?

Upvotes: 1

Views: 437

Answers (1)

Pavel
Pavel

Reputation: 113

This behavior is by design - there was no connection established, no logon done, so no OnLogout event after network failure when connecting. You can see the source code for that part - FromEarlyIntercept is also not triggered in this case. QuickFix/n just logs the error and will try to reconnect after ReconnectInterval seconds.

try
        {
            t.Connect();
            t.Initiator.SetConnected(t.Session.SessionID);
            t.Session.Log.OnEvent("Connection succeeded");
            t.Session.Next();
            while (t.Read())
            { }
            if (t.Initiator.IsStopped)
                t.Initiator.RemoveThread(t);
            t.Initiator.SetDisconnected(t.Session.SessionID);
        }
        catch (IOException ex) // Can be exception when connecting, during ssl authentication or when reading
        {
            t.Session.Log.OnEvent("Connection failed: " + ex.Message);
        }
        catch (SocketException e) 
        {
            t.Session.Log.OnEvent("Connection failed: " + e.Message);
        }

Upvotes: 2

Related Questions