Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not increment NextTargetMsgSeqNum for out of sequence Logout and Test Requests #645

Merged
merged 2 commits into from
Jun 25, 2024

Conversation

momin-javed
Copy link
Contributor

@momin-javed momin-javed commented Jun 14, 2024

If an out-of-sequence Logout or Test Request is received, either during inSession or resendState, it should not result in incrementing the next expected target sequence number, or else we have a chance of missing a message.

Consider the scenario below from the point of view of an Initiator.
We receive a Logout request from Acceptor:

FIX incoming [FIX.4.2:SENDER->TARGET |8=FIX.4.2|35=5|34=100|
FIX event [FIX.4.2:SENDER->TARGET - Received logout request]
FIX event [FIX.4.2:SENDER->TARGET - Sending logout response]
FIX outgoing [FIX.4.2:SENDER->TARGET - |8=FIX.4.2|35=5|34=10|
FIX event [FIX.4.2:SENDER->TARGET - Disconnected]

After some time we try to Logon again:

FIX event [FIX.4.2:SENDER->TARGET - Sending logon request]
FIX outgoing [FIX.4.2:SENDER->TARGET - |8=FIX.4.2|35=A|34=11|
FIX incoming [FIX.4.2:SENDER->TARGET |8=FIX.4.2|35=A|34=105|
FIX event [FIX.4.2:SENDER->TARGET - Received logon response]
FIX event [FIX.4.2:SENDER->TARGET - MsgSeqNum too high, expecting 101 but received 105]
FIX event [FIX.4.2:SENDER->TARGET - Sent ResendRequest FROM: 101 TO: 0]
FIX outgoing [FIX.4.2:SENDER->TARGET - |8=FIX.4.2|35=2|34=12|7=101|16=0|

But we receive another Logout request from Acceptor:

FIX incoming [FIX.4.2:SENDER->TARGET |8=FIX.4.2|35=5|34=106|
FIX event [FIX.4.2:SENDER->TARGET - Received logout request]
FIX event [FIX.4.2:SENDER->TARGET - Sending logout response]
FIX outgoing [FIX.4.2:SENDER->TARGET - |8=FIX.4.2|35=5|34=13|
FIX event [FIX.4.2:SENDER->TARGET - Disconnected]

However, this out-of-sequence Logout request received from the Acceptor increments the next expected target sequence number from 101 to 102. Hence, when we try to Logon again:

FIX event [FIX.4.2:SENDER->TARGET - Sending logon request]
FIX outgoing [FIX.4.2:SENDER->TARGET - |8=FIX.4.2|35=A|34=14|
FIX incoming [FIX.4.2:SENDER->TARGET |8=FIX.4.2|35=A|34=107|
FIX event [FIX.4.2:SENDER->TARGET - Received logon response]
FIX event [FIX.4.2:SENDER->TARGET - MsgSeqNum too high, expecting 102 but received 107]
FIX event [FIX.4.2:SENDER->TARGET - Sent ResendRequest FROM: 102 TO: 0]
FIX outgoing [FIX.4.2:SENDER->TARGET - |8=FIX.4.2|35=2|34=15|7=102|16=0|

Therefore, we have now permanently skipped asking for a resend of sequence number 101, even though we never received it. This will result in us missing sequence number 101 from the Acceptor.

This PR addresses this issue for out-of-sequence Logout Requests as well as for Test Requests which seem to have the same problem.

in_session.go Outdated Show resolved Hide resolved
@momin-javed
Copy link
Contributor Author

@ackleymi any thoughts on this?

@ackleymi ackleymi merged commit 358abef into quickfixgo:main Jun 25, 2024
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants