Re: [Quickfix-developers] sendToTarget and "SessionNotFound" woes...
Brought to you by:
orenmnero
From: <or...@qu...> - 2008-07-01 15:23:47
|
MsgType is a header field, but you are adding it to the main message body, so QuickFIX cannot locate it. If you add it to the header you should be fine. --oren > -------- Original Message -------- > Subject: [Quickfix-developers] sendToTarget and "SessionNotFound" > woes... > From: Alex Marangos <ale...@ya...> > Date: Tue, July 01, 2008 7:10 am > To: qui...@li... > QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/index.html > QuickFIX Support: http://www.quickfixengine.org/services.html<hr>Hi all, > > I'm writing a simple QuickFix application (just evaluating it for now) in C#, and I'm having problems getting sendToTarget to work.... Sorry for the length of this email, but I'm completely baffled by what does and doesn't work... > > So far, I've created a ThreadedSocketInitiator with the following config: > > [DEFAULT] > ConnectionType=acceptor > SocketAcceptPort=40000 > ReconnectInterval=60 > FileStorePath=Logs\QuickFIX.Acceptor > FileLogPath=Logs\QuickFIX.Acceptor > PersistMessages=Y > > [SESSION] > BeginString=FIX.4.0 > SenderCompID=ACCEPTOR40 > TargetCompID=INITIATOR40 > StartTime=00:00:00 > EndTime=23:59:59 > HeartBtInt=5 > UseDataDictionary=Y > DataDictionary=FIX40.xml > ValidateFieldsHaveValues=Y > ValidateFieldsOutOfOrder=N > > On the receiving end I have an instance of the executor running, with the appropriate session configuration. I can start both applications and the sessions connect and heartbeat. > > Now I'm confused as to what's needed when creating a FIX message and using sendToTarget() in my application, as in some cases it works, in others it doesn't. The code to create and send the message looks like: > > 01: stringbeginString = "FIX.4.0"; > 02: stringsenderCompID = "INITIATOR40"; > 03: stringtargetCompID = "ACCEPTOR40"; > 04: QuickFix.Messagefixmsg = newQuickFix.Message(); > 05: QuickFix.BeginStringbgn = newBeginString(beginString); > 06: QuickFix.SenderCompIDscid = newSenderCompID(senderCompID); > 07: QuickFix.TargetCompIDtcid = newTargetCompID(targetCompID); > 08: QuickFix.MsgTypemsgType = newQuickFix.MsgType(QuickFix.MsgType.ORDER_SINGLE); > 09: QuickFix.OrdTypeordType = newQuickFix.OrdType(QuickFix.OrdType.MARKET); > 10: intrnd = newSystem.Random().Next(); > 11: QuickFix.ClOrdIDclOrdID = newQuickFix.ClOrdID(rnd.ToString()); > 12: QuickFix.HandlInsthandlInst = newQuickFix.HandlInst(QuickFix.HandlInst.AUTOMATED_EXECUTION_ORDER_PUBLIC); > 13: QuickFix..OrderQtyorderQty = newQuickFix.OrderQty(1000); > 14: QuickFix.Symbolsymbol = newQuickFix.Symbol("IBM"); > 15: QuickFix.Sideside = newQuickFix.Side(QuickFix.Side.BUY); > 16: fixmsg.getHeader().setField(bgn); > 17: fixmsg.getHeader().setField(scid); > 18: fixmsg.getHeader().setField(tcid); > 19: fixmsg.setField(ordType); > 20: fixmsg.setField(msgType); > 21: fixmsg.setField(clOrdID); > 22: fixmsg.setField(handlInst); > 23: fixmsg.setField(symbol); > 24: fixmsg.setField(side); > 25: fixmsg.setField(orderQty); > 26: fixmsg.setField(ordType); > 27: Console.WriteLine("Message to send: {0}", fixmsg.ToString()); > 28: Console.WriteLine("BeginString: {0}", beginString); > 29: Console.WriteLine("SenderCompID: {0}", senderCompID); > 30: Console.WriteLine("TargetCompID: {0}", targetCompID); > 31: SessionIDsID = newSessionID(beginString, senderCompID, targetCompID); > 32: Console.WriteLine("Session Exists: {0}", Session.doesSessionExist(sID)); > 33: Session.sendToTarget(fixmsg, senderCompID, targetCompID); > > This throws a "SessionNotFound" error. Session.doesSessionExist(sID) returns "True", however... > > And if I replace sendToTarget() with: > Session.sendToTarget(fixmsg, sID); > > I get an exception as follows: > System.Runtime.InteropServices.SEHException: External component has thrown an exception. > at _CxxThrowException(Void* , _s__ThrowInfo* ) > at FIX.FieldMap.getField(FieldMap* , FieldBase* field) > at Application.create(Application* , Message* unmanaged) > at Application.toApp(Application* , Message* message, SessionID* sessionID) > at FIX.Session.sendToTarget(Message* , SessionID* ) > at QuickFix.Session.sendToTarget(Message message, SessionID sessionID) > at QuickFIXMessageProvider.MessageProvider.Test2() in C:\Temp\QuickFIX\Prototypes\Test\Properties\MessageSender.cs:line 357 > at QuickFIXMessageProvider.MessageProvider.ReceivedMsg(Message msg, String SenderCompID, String TargetCompID, String BeginString) in C:\Temp\QuickFIX\Prototypes\Test\Properties\MessageSender.cs:line 245 > Now, if I change my code above to use QuickFix40.NewOrderSingle (instead of QuickFix.Message), it works... > So just change line 04 to read: > > 04: QuickFix40.NewOrderSinglefixmsg = newQuickFix40.NewOrderSingle(); > (commenting out lines 08 and 20 which set the MsgType) > > With the above changes (using version-specific message class), sendToTarget works fine, regardles of which method signature I use... (and sendToTarget(fixmsg, sID) doesn't throw the above exception either, it works fine). > > I'd like to avoid using FIX version-specific code if possible, which is why I'm trying to figure out what I need to do to get my code above to work correctly. > > Any help would be appreciated. > > Rgds, > Alexandros > __________________________________________________________ > Not happy with your email address?. > Get the one you really want - millions of new email addresses available now at Yahoo! http://uk.docs.yahoo.com/ymail/new.html<hr>------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php<hr>_______________________________________________ > Quickfix-developers mailing list > Qui...@li... > https://lists.sourceforge.net/lists/listinfo/quickfix-developers |