Charles - 2007-11-29

If a remote engine send a bad message that can not be parsed an exception is thrown.  The parse catch block generates a session level reject and send it back to the client so the same bad message is never sent again.  Of coarse the passed CheckSum/BodyLen so the message was send corrupt by the remote side and will always arrive corrupted.

Back to the problem...

When generating the reject it tries to parse the MsgType to include in the reject.  The ParseMsgType function has a bug that returns the wrong value as shown bellow in tag "372=D|49".

8=FIX.4.2|9=101|35=3|49=ZZZ|56=XXX|34=2|52=20071129-16:06:16|45=2|371=200|372=D|49|373=5|58=PARSE ERROR ON TAG 200|10=161|

To fix the bug it's a single line change when find the end of the field.  I was using the wrong constant when calling IndexOf.

Old Source

public string ParseMsgType(string sMessage)
{
int iStart = sMessage.IndexOf(sMsgTypePrefix);
if (iStart == -1)
return null;
iStart += sMsgSeqNumPrefix.Length;

int iEnd = sMessage.IndexOf(TAG_DELIM, iStart);
if (iEnd == -1)
return null;

string sMsgType = sMessage.Substring(iStart, iEnd - iStart);

return sMsgType;
}

New Source

int iEnd = sMessage.IndexOf(FIELD_DELIM, iStart);