{{Quickfixn}} How Should A Session Be Closed

Ian Clements ian at investmentsoftwareltd.com
Tue Mar 21 03:19:06 PDT 2017


Hi Mike,

Sorry for the delay in getting back to you.  Essentially we run our FIX engine inside a Windows Service so if for whatever reason someone stops the service we try and shutdown our sessions neatly.  However the main thing is at the end of every day we have to shut down the FIX engine to remove locks on the log files so that we can perform housekeeping/archiving of the files.  This is done when all sessions have completed and logged out for the day (Using login/logout times as you mentioned).  However on very rare occasions QuickFix is throwing the unhandled exception shown in my previous email and shown again below which then crashes our Windows Service completely.  I have seen other people raise this issue and it potentially seems to be a bug in the QuickFix engine itself however I wanted to check that it wasn’t related to the way I was shutting down the engine at the end of the day.

   at QuickFix.FileLog.OnEvent(System.String)
   at QuickFix.Transport.SocketInitiator.SocketInitiatorThreadStart(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ThreadHelper.ThreadStart(System.Object)


Many thanks,
Ian.

From: Quickfixn [mailto:quickfixn-bounces at lists.quickfixn.com] On Behalf Of Mike Gatny
Sent: Wednesday, March 15, 2017 1:14 PM
To: Mailing list for QuickFIX/n <quickfixn at lists.quickfixn.com>
Subject: Re: {{Quickfixn}} How Should A Session Be Closed

Hi Ian,

Could you provide a little background on what your use case is for stopping particular Sessions manually?
It is more typical to let the Initiator manage stopping and starting Sessions for you, e.g. using the StartTime/EndTime SessionSettings, or by calling Stop() on the Initiator itself to stop all Sessions.
Depending on your use case the Initiaiator's AddSession/RemoveSession methods might be useful to you.  See: https://github.com/connamara/quickfixn/blob/master/QuickFIXn/AbstractInitiator.cs#L130-L157

--
Mike Gatny
Connamara Systems, LLC

On Wed, Mar 15, 2017 at 6:10 AM, Ian Clements <ian at investmentsoftwareltd.com<mailto:ian at investmentsoftwareltd.com>> wrote:
Hi all,

Currently I have the code below to stop a Session.

                try { session.Disconnect("FIX Engine: Stopped."); }
                catch (Exception ex)
                {
                    var msg = string.Format("FIX Engine: Session Disconnect Error for {0} - {1}", sessionID.ToString(), ex.ToString());
                    logger.Write(msg, System.Diagnostics.EventLogEntryType.Error, LoggerPriority.High);
                }
                session = null;

However we have intermittently been getting the following error when our FIX engine restarts –

Description: The process was terminated due to an unhandled exception.
Exception Info: System.ObjectDisposedException
Stack:
   at QuickFix.FileLog.OnEvent(System.String)
   at QuickFix.Transport.SocketInitiator.SocketInitiatorThreadStart(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ThreadHelper.ThreadStart(System.Object)

Is this potentially due to us not disconnecting properly?  Should I be calling Logout and then Disconnect or just Logout?

Many thanks,



_______________________________________________
Quickfixn mailing list
Quickfixn at lists.quickfixn.com<mailto:Quickfixn at lists.quickfixn.com>
http://lists.quickfixn.com/listinfo.cgi/quickfixn-quickfixn.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.quickfixn.com/pipermail/quickfixn-quickfixn.com/attachments/20170321/51e5ed8b/attachment-0002.htm>


More information about the Quickfixn mailing list