Re: [Quickfix-developers] sendToTarget and "SessionNotFound" woes...
Brought to you by:
orenmnero
From: Alex M. <ale...@ya...> - 2008-07-01 13:21:31
|
Your question pointed me in the right direction, I had compared the messages before, but it never occurred to me to look at the ordering of the fields closely: Working (QuickFix40.NewOrderSingle): Message to send: 8=FIX.4.0 | 9=78 | 35=D | 49=INITIATOR40 | 56=ACCEPTOR40 | 11=1786971871 | 21=2 | 38=1000 | 40=1 | 54=1 | 55=IBM | 10=044 | Not working (QuickFix.Message): Message to send: 8=FIX.4.0 | 9=78 | 49=INITIATOR40 | 56=ACCEPTOR40 | 11=1435599980 | 21=2 | 35=D | 38=1000 | 40=1 | 54=1 | 55=IBM | 10=042 | Even though the fields have the same values (minus ClOrdID, of course), I realised how dumb I was (head bashing on the wall right now), as the MsgType should have been part of the header not the message body. So changing line 20 to: 20: fixmsg.getHeader().setField(msgType); did the trick! I can't believe I spent so much time trying to figure such a silly mistake out! Guess it always helps to have another set of eyes look at things.... Thanks for your help! Rgds, Alexandros ----- Original Message ---- From: John Haldi <jo...@ha...> To: Alex Marangos <ale...@ya...> Sent: Tuesday, 1 July, 2008 2:01:34 PM Subject: RE: [Quickfix-developers] sendToTarget and "SessionNotFound" woes... Out of curiosity, could you provide the output of calling Console.WriteLine(fixmsg.tostring) so I could take a peek and see if there's something you've missed in the construction of the message (specifically the message header fields)? It would be interesting to compare this message to the one created by the strongly type version from quickfix40.newOrderSingle.... jh ________________________________ From: qui...@li... [mailto:qui...@li...] On Behalf Of Alex Marangos Sent: Tuesday, July 01, 2008 8:43 AM To: qui...@li... Subject: Re: [Quickfix-developers] sendToTarget and "SessionNotFound" woes... Same errors.. Apologies for the confusion, I was trying various combinations and I copied the latest (working) version of my INI file when I was using the type-safe code. Rgds, Alexandros ----- Original Message ---- From: John Haldi <jo...@ha...> To: Alex Marangos <ale...@ya...> Sent: Tuesday, 1 July, 2008 1:36:23 PM Subject: RE: [Quickfix-developers] sendToTarget and "SessionNotFound" woes... Alex, I'm a little confused. If you want to write FIX-version agnostic code, why are you using the DataDictionary for 4.0? I don't know the details under the hood for the SendToTarget method, but what happens if you change UseDataDictionary to N, strip the DataDictionary entry from the config file completely, and then use the SendToTarget(msg,sID) signature with the quickfix.message object? John ________________________________ From: qui...@li... [mailto:qui...@li...] On Behalf Of Alex Marangos Sent: Tuesday, July 01, 2008 8:11 AM To: qui...@li... Subject: [Quickfix-developers] sendToTarget and "SessionNotFound" woes... 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! No virus found in this incoming message. Checked by AVG. Version: 8.0.101 / Virus Database: 270.4.3/1526 - Release Date: 6/30/2008 8:43 AM ________________________________ Not happy with your email address? Get the one you really want - millions of new email addresses available now at Yahoo! No virus found in this incoming message. Checked by AVG. Version: 8.0.101 / Virus Database: 270.4.3/1528 - Release Date: 7/1/2008 7:26 AM __________________________________________________________ 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 |