quickfixgo / quickfix

The Go FIX Protocol Library :rocket:

Home Page:https://www.quickfixgo.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

initiator reconnect loop when state is lost

rubensayshi opened this issue · comments

full disclosure: I'm fairly new to FIX
I've been messing around with quickfix and the session lifecycle and was interested to see how quickfix would handle the initiator loosing it's state entirely and starting with a clean state.

what seems to happen is that if MsgSeqNum on the Logon of the initiator doesn't match the TargetMsgSeqNum of the acceptor, the acceptor will disconnect instantly.
then the initiator will reconnect after 30s and will send Login with a +1 MsgSeqNum.

and this repeats, until eventually (depending on the msg history) the initiator has reached the proper MsgSeqNum and then the acceptor will actually accept the connection, the initiator sends a ResendRequest and we're good to go!

I think the right course of action would be for the initiator to send a reset?
but I can't seem to figure out how to detect this scenario and trigger that, or maybe the check in shouldSendReset should be an OR instead of AND?

I think FIX would require you to manually set your session's sequence number to the "right thing". But if you do, and you've lost data, the other side won't know exactly how much data you've lost (which could matter for resends, which is a minor use-case). The idea of FIX is to be a reliable transmission line, and any cases of data loss require manual intervention. Don't lose data :)

If you don't care about data loss, then you can connect with 141=Y, which will wipe the state on the remote side as well.