quickfix-j / quickfixj

QuickFIX/J is a full featured messaging engine for the FIX protocol. - This is the official project repository.
http://www.quickfixj.org
Other
959 stars 613 forks source link

Resend range variables are not reset if the resend request is rejected #888

Open vishwajit2 opened 1 day ago

vishwajit2 commented 1 day ago

Describe the bug Upon detecting the sequence number higher than the expected, the FIX client sends a resend request. But few vendors reject the resend requests in scenarios when those resend requests could not be fulfilled. They also provide with the starting sequence number from which we can request in the reject message. QuickFix session layer should handle this and reset the resend range that was set back to intitial state as there is no active state.

But currently resend range ia not reset, this makes Quickfix think that there is an active resend request. Hence it does not attempt to send the resend request next time a message with higher sequence number is received.

The issue that I am facing because of this: I intent to handle reject message in fromAdmin and modify the next expected target sequence number to the starting sequence number that we got in reject message. So the next time QuickFix session layer sends the resend request, it uses current start sequence number. But with current implementation resend request is not sent at all.

To Reproduce Send a message with sequence number higher than expected. Client will send the resend request. Send the reject message in response to the Resend Request and continue sending the messages with higher sequence numbers.

Expected behavior Quickfix should detect that Rejeci message is in reference to the Resend request and resend range should be reset back to initial state. As resend range is private variable of session without any setters. This should be handled within Session class.

system information:

chrjohn commented 1 day ago

How can a resend request be rejected? Does not sound like standard FIX to me. Since this does not seem standard maybe we could provide some means that users could reset the resend state. But need to think about it. Do you have an example message flow from your logs?

vishwajit2 commented 23 hours ago

I can not share the exact logs here but can describe rhe message flow in detail.

  1. Client sends Logon to the server. Server sends back the logon response with 34 = 14000. Client had the next expected sender number as 1.
  2. Client sends the resend request from 1 to 4000 (4000 is the chunk size here). But Server can only resend the messages from 7001. So it sends a session level reject (MsgType : 3)with a field that contains the sequence number from which messages can be resent (i.e. resend request can be processed).
  3. Client handles this in fromAdmin by modifying session's next expected target number to 7001.
  4. Client receives a business message from server with sequence number 14001. Client does not send resend request saying "Resend request from 1 to 4000 already in progress, not sending another" and the curri message is added to the queue.

A work around we are thinking of is disconnecting the session (which will reset the resend range) and connecting back again. But this is not a good solution and some feature from the quick fix to achieve this would be appreciated.