Re: sendToTarget and "SessionNotFound" woes...

View: New views
1 Messages — Rating Filter:   Alert me  

Re: sendToTarget and "SessionNotFound" woes...

by Alex Marangos :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/index.html
QuickFIX Support: http://www.quickfixengine.org/services.html


Shane,
 
Thanks for the quick response. I'm trying to avoid using type-safe code, as I'd be handling multiple FIX versions at the same time and don't want to be re-writing code where not necessary. I already have a FIX-version specific process upstream, and I'm looking for a FIX engine that can act as a version-agnostic "middleware" to just create the messages and pass them on to the receiving end [as well as handling session-level aspects of connectivity etc].
Rgds,
Alexandros

 
----- Original Message ----
From: Shane Trotter <strotter@...>
To: Alex Marangos <alex.marangos@...>
Cc: quickfix-developers@...
Sent: Tuesday, 1 July, 2008 1:17:42 PM
Subject: Re: [Quickfix-developers] sendToTarget and "SessionNotFound" woes...

Alex,

I believe using the type-safe/FIX-version specific code is the correct way to do it.

Check http://quickfixengine.org/quickfix/doc/html/csharp/sending_messages_4.html for reference.  Note the use of the QuickFix41 namespace.

This is because each version is different, and ideally it should validate the correctness of a message of each version.

--
Shane Trotter
Connamara Systems, LLC

On Tue, Jul 1, 2008 at 7:10 AM, Alex Marangos <alex.marangos@...> wrote:
QuickFIX Documentation: http://www.quickfixengine.org/quickfix/doc/html/index.html
QuickFIX Support: http://www.quickfixengine.org/services.html


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: string beginString = "FIX.4.0";
02:
string senderCompID = "INITIATOR40";
03: string targetCompID = "ACCEPTOR40";
04: QuickFix.
Message fixmsg = new QuickFix.Message();
05: QuickFix.
BeginString bgn = new BeginString
(beginString);
06: QuickFix.
SenderCompID scid = new SenderCompID
(senderCompID);
07: QuickFix.
TargetCompID tcid = new TargetCompID
(targetCompID);
08: QuickFix.
MsgType msgType = new QuickFix.MsgType(QuickFix.MsgType
.ORDER_SINGLE);
09: QuickFix.
OrdType ordType = new QuickFix.OrdType(QuickFix.OrdType.MARKET);
10: int rnd = new System.Random
().Next();
11: QuickFix.
ClOrdID clOrdID = new QuickFix.ClOrdID
(rnd.ToString());
12: QuickFix.
HandlInst handlInst = new QuickFix.HandlInst(QuickFix.HandlInst
.AUTOMATED_EXECUTION_ORDER_PUBLIC);
13: QuickFix.
OrderQty orderQty = new QuickFix.OrderQty
(1000);
14: QuickFix.
Symbol symbol = new QuickFix.Symbol("IBM"
);
15: QuickFix.
Side side = new QuickFix.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: SessionID sID = new SessionID(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.NewOrderSingle fixmsg = new QuickFix40.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!

-------------------------------------------------------------------------
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
_______________________________________________
Quickfix-developers mailing list
Quickfix-developers@...
https://lists.sourceforge.net/lists/listinfo/quickfix-developers




Not happy with your email address?
Get the one you really want - millions of new email addresses available now at Yahoo!
-------------------------------------------------------------------------
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
_______________________________________________
Quickfix-developers mailing list
Quickfix-developers@...
https://lists.sourceforge.net/lists/listinfo/quickfix-developers
LightInTheBox - Buy quality products at wholesale price