System doesn't break TCP/IP connection when sending Logon message with ResetSeqNumFlag (141)=Y and Invalid MsgSeqNum (!=1)
Describe the bug We’ve developed a fix trading gateway using quickfixj library.
When a user sends a Logon message to the system for a user, with ResetSeqNumFlag = Y and MsgSeqNum !=1 we expect the system to break the TCP/IP connection after sending a Logout message due to the MsgSeqNum being invalid.
To Reproduce Step to reproduce:
- Establish TCP/IP connection
- Send Logon message to the system with SenderCompID of active user
- Receive Logon message from the system
- Receive Heartbeat message
- Send Heartbeat message
- Send Logout message
- Receive Logout message
- Send Logon message to the system with SenderCompID of active user and ResetSeqNumFlag = Y and MsgSeqNum !=1
- Receive Logout message
Expected behavior
- Expected behavior: logout message from the system since MsgSeqNum != 1
Actual behavior: System isn’t sending logout. Instead sends a logon response.
system information:
- OS: [e.g. Linux]
- Java version [e.g. JDK11]
- QFJ Version [e.g. 2.0.3]
Wow, I had to do some FIX spec digging to find out if this really is a bug. At the moment I am not sure since I didn't find something that applies to this situatuon. Can you present some excerpt from the FIX spec that says that this really is a bug? Thanks, Chris.
According to FIX_Session_Layer_with_Errata_November_2020.pdf Section 5.4.7
5.4.7 Validation of message sequence numbers
If a received message has a MsgSeqNum(34) less than NextNumIn, a serious error exists. The FIX session and transport
layer connection should be terminated unless the message received is:
• a SequenceReset(35=4) message with PossDupFlag(43) present with a value of “Y”.
• any message of a message type that supports retransmission with a PossDupFlag(43) present with a value
of “Y”.
• a Logon(35=A) message with ResetSeqNumFlag(141) present with a value of “Y”.
_**If a received message has a MsgSeqNum(34) greater than NextNumIn, a serious error exists. The FIX session and
transport layer connection should be terminated.**_
With regards to the mentioned scenario the connection should be terminated in scenarios MsgSeqNumber is greater than the expected MsgSeqNumber
Many thanks, Harinda
Hmm, that is actually the description from the LFIXT session profile.
The Lightweight FIXT session profile (LFIXT) is a restriction of the FIXT session profile. LFIXT eliminates the use of session layer retransmission of messages to simplify the session layer protocol.
So not actually what QFJ is implementing by default. I will check whether I find something useful in the FIX protocol forum and report back.
BTW, your initial request was about sequence number being different than 1, the excerpt from the spec above talks about the sequence number being greater than the next expected seqnum.
BTW, your initial request was about sequence number being different than 1, the excerpt from the spec above talks about the sequence number being greater than the next expected seqnum.
Yes, in this scenario the expected seqNum is 1. You are correct , it should be changed to being greater than the seqNum 1.
So not actually what QFJ is implementing by default. I will check whether I find something useful in the FIX protocol forum and report back.
Many thanks
Another question @harinda05
Actual behavior: System isn’t sending logout. Instead sends a logon response.
But it does reset the sequence number and the session is up and running after this?
Edit: I have created a forum post: https://forum.fixtrading.org/t/sequence-number-on-logon-message-when-resetseqnumflag-y/16562
While writing it it occurred to me that maybe you are confusing two scenarios: https://www.fixtrading.org/standards/fix-session-layer-online/#using-resetseqnumflag141-to-reset-fix-session-for-24-hour-connectivity and https://www.fixtrading.org/standards/fix-session-layer-online/#using-resetseqnumflag141-to-reset-fix-session-during-fix-connection-establishmentresetseqnumflag
Your case seems to be the latter (since the seqnum is reset after disconnection) but there is no mentioning that the sequence number has to be 1.
But it does reset the sequence number and the session is up and running after this?
Yes this is correct.
Edit: I have created a forum post: https://forum.fixtrading.org/t/sequence-number-on-logon-message-when-resetseqnumflag-y/16562
Thanks for opening thread.
While writing it it occurred to me that maybe you are confusing two scenarios:
https://www.fixtrading.org/standards/fix-session-layer-online/#using-resetseqnumflag141-to-reset-fix-session-for-24-hour-connectivity and https://www.fixtrading.org/standards/fix-session-layer-online/#using-resetseqnumflag141-to-reset-fix-session-during-fix-connection-establishmentresetseqnumflag
Thanks for pointing this out. I will follow up on this as well.
In my opinion it does not make sense to impose restrictions on the sequence number of the Logon message when the intention is to reset the sequence numbers anyway. This is followed in #549 as well. I will close this issue for now. Please reopen if you have any new information.