Open DHirani opened 6 years ago
Hello, I have simulated a drop connection of my QF/n Initiator after a successful LogOn, establishing an outbound deny rule on the firewall of the socket initiator. I see that QF/n generates an exception log in event's log file of type System.Net.Sockets.SocketException (10053) but IApplication hasn't notified about this event, so the Initiator believes that the session is still logged on.
Thank you in advance
Regards
This is kind of an old issue but can we create an OnConnectException similar to what quickfix/j has on their SessionStateListener?
raise an event here in the SocketInitiator.cs if an exception is thrown?
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
{
exceptionEvent = $"Connection failed: {ex.Message}";
}
catch (SocketException e)
{
exceptionEvent = $"Connection failed: {e.Message}";
}
catch (System.Security.Authentication.AuthenticationException ex) // some certificate problems
{
exceptionEvent = $"Connection failed (AuthenticationException): {ex.Message}";
}
catch (Exception ex)
{
exceptionEvent = $"Unexpected exception: {ex}";
}
Example event message Session FIX.4.4:TEST->TEST2 disconnecting: System.Net.Sockets.SocketException (0x80004005): An existing connection was forcibly closed by the remote host at QuickFix.SocketInitiatorThread.ReadSome(Byte[] buffer, Int32 timeoutMilliseconds) at QuickFix.SocketInitiatorThread.Read()
If the broker drops the session the Quickfixn silently hides the message and logs it to the event log file, however it should notify IApplication.Disconnect when this happens.
See code in Session.cs Line 418. this.Log.OnEvent("Session " + this.SessionID + " disconnecting: " + reason); It should call this.Application.OnLogout
`public void Disconnect(string reason) { lock (sync) { if (null != responder) { this.Log.OnEvent("Session " + this.SessionID + " disconnecting: " + reason); responder.Disconnect(); responder = null; } else { this.Log.OnEvent("Session " + this.SessionID + " already disconnected: " + reason); }
`