Page tree
Skip to end of metadata
Go to start of metadata

Overview

This article answers most frequently asked questions regarding Sequence Numbers, their usage and ways to manage them (manually or automatically) with the help of different properties which can be specified in engine.properties configuration file.

The FIX protocol assumes complete ordered delivery of messages between counterparties. It means there is no acknowledgment of individual message delivery. Instead of this, the following control mechanism is used:

  • Each FIX message has a unique sequence number (MsgSecNum (34) tag).
  • Counterparties must control that sequence numbers of outgoing messages and incoming messages, they should be continuous and sequential.

For this, the counterparty establishes an independent incoming and outgoing sequence numbers for each FIX session. Sequence numbers are initialized at the start of the FIX session starting at 1 (one) and increment throughout the session.

Incoming sequence number is a counter for incoming messages.

Outgoing sequence number is a counter for outgoing messages.

Monitoring of incoming sequence number allows counterparties to identify and react onto disturbing the synchronization. There are two types of sequence numbers desynchronization:

    • Sequence number is too high, i.e. a gap in sequence numbers is detected. It indicates that some messages were missed. The counterparty initiates standard message recovery process.
    • Sequence number is too low – it indicates some serious problem and leads to immediate session termination.
  • In order to maintain the integrity of connection Heartbeat and Test Request messages are used.

In accordance with FIX protocol standard, after the correct FIX session termination (by the Logout message) sequence numbers are reset to 1. If connection is terminated 'non-gracefully' sequence numbers will continue when the session is restored.

In fact a lot of service providers never reset sequence numbers during the day. There are also some, who reset sequence numbers once per week. There are several cases to handle such deviation from standard in FIX Antenna: 

  • Intraday Logout Tolerance mode makes that FIX session sequence numbers always will continue on the next connection.

  • Force Sequence Number Reset mode makes the session reset sequence number every time on logon and forces the counterparty to do the same.

Intraday Logout Tolerance Mode

In the Intraday Logout Tolerance mode, the FIX Antenna will continue sequence numbers even in case the FIX session is re-established after correct termination (by the Logout message). The configuration property IntradayLogoutTolerance can be set to ‘true’ or ‘false’ to turn this mode on or off, correspondingly.

If set to ‘false’ then the session does not exist after correct termination and hence a newly created session with the same SenderCompID and TargetCompID starts with 1 as it is specified by the FIX protocol.

In the Intraday Logout Tolerance mode, the sequence number is never reset during the day. It means that the Initiator should initiate session recovery by sending Logon message with MsgSeqNum = <last outgoing sequence number> + 1; and will expect confirming Logon message with MsgSeqNum = <last incoming sequence number> + 1. If a gap is detected, standard message recovery or gap filling process takes place.

Note: It is crucial that both sides – the initiator and the acceptor – work in the same mode. Otherwise, the ‘sequence number is too low’ fatal error appears when the session is reestablished.

During the end-of-day procedure, session logs are archived. So, because the FIX Antenna stores session state in logs files, absence of such file will be treated as session being created from scratch and hence sequence numbers start from 1.


Force Sequence Number Reset Mode

In the Force Sequence Number Reset mode, the FIXEdge will reset outgoing and incoming sequence number on every time on logon and force the counterparty to do the same via sending the tag ResetSeqNumFlag (141)  = Y in Logon message.

The configuration property ForceSeqNumReset is used to set the mode. The following values can be applied for the property:

  • Value ‘0’ or ‘false’ – mode is off, do not use tag ResetSeqNumFlag (141)

  • Value ‘1’ or ‘true’ – Enable SeqNum reset at first time of session initiation

  • Value ‘2’ – reset sequence number at every logon

This mode is used to resolve ‘sequence number is too low’ problem. It usually occurs as a result of applying the Intraday Logout Tolerance mode only by one of counterparty or after ‘non-graceful' session termination log-files are cleared on the one side and kept on the other side.

Note: This is not a recommended way since messages sent during inactivity time will be lost. Also it is recommended to make sure that other counterparty supports this functionality before relying on it.

The matrix of different combinations

ForceSeqNumReset012
IntradayLogoutTolerance 
true

FIX Antenna will always use the same set of logs and will never reset sequence numbers.
After logs cleanup FIX Antenna will send Logon with SeqNum=1 and without ResetSeqNum flag.

This is the most safe combination, but you have to make sure that your counterparties don’t reset sequence numbers on their side. Otherwise, they will send you confirming Logon with SeqNum=1 and FIX Antenna will terminate the session.

FIX Antenna will send only first Logon with ResetSeqNum flag (141=Y), after that it will always use the same set of logs and will reset sequence numbers only after logs cleanup.

Whether this is the first Logon or not, is defined by presence of logs in log directory.

FIX Antenna will always send Logon with ResetSeqNum flag (141=Y).
IntradayLogoutTolerance doesn’t work for this case, new set of logs will be created after each Logout.

false

FIX Antenna will create new set of logs after Logout.
Next Logon will be sent with SeqNum=1 and without ResetSeqNum flag.

FIX Antenna will create new set of logs after Logout.
Next Logon will be sent with SeqNum=1 and with ResetSeqNum flag (141=Y).

Each Logon will be sent with SeqNum=1 and with ResetSeqNum flag (141=Y).

Other cases of sequence number handling

The property ResetSeqNumAfter24hours can be used for sequence number resetting after each 24 hour period via sending the tag ResetSeqNumFlag (141) = Y in Logon message.

Sequence number handling FAQ

When sequence numbers reset happens?

In accordance with FIX protocol standard, after the correct FIX session termination (by the Logout message) sequence numbers are reset to 1. Correct session termination means that both counterparties has exchanged with Logout messages. In terms of FIX Antenna parameters it means that Intraday Logout Tolerance Mode and Force Sequence Number Reset Mode are switched off in engine.properties configuration file:

  • IntradayLogoutTolerance = false;
  • ForceSeqNumReset = 0.

During the end-of-day procedure, session logs are archived. After logs cleanup sequence numbers will be always reset and Logon with SeqNum=1 will be sent.

How to reset sequence numbers after logout?

In order to reset sequence numbers after each logout, you need Logout Tolerance Mode to be switched off: IntradayLogoutTolerance = false in engine.properties configuration file.

It is recommended to move FIX session persistent files from the logs directory into backup directory to reset sequence numbers. Since FIX Antenna stores session state in those files, absence of such file in the logs directory will be treated as session being created from scratch and thus sequence numbers will be set to 1. Files can be moved into backup directory during the End-Of-Day or End-Of-Week procedure.

If you also need to force the counterparty to do the same (to reset sequence number at every logon), you may switch on Force Sequence Number Reset mode: ForceSeqNumReset = 2 in engine.properties configuration file.

This is not a recommended way since messages sent during inactivity time will be lost. Also it is recommended to make sure that counterparty supports this functionality before relying on it.

How to not reset sequence numbers after logout?

If you do not want sequence numbers to be reset every time after logout, the IntradayLogoutTolerance property should be set to "true": IntradayLogoutTolerance = true in engine.properties configuration file.

IntradayLogoutTolerance mode makes the session always go to the non-gracefully terminated state, which means the sequence numbers will continue on the next connection. 

IntradayLogoutTolerance mode will not work if ForceSeqNumReset = 2

How to reset sequence numbers only at daily first logon?

In order to reset sequence numbers only for first daily logon, you need to specify the following values of properties in engine.properties configuration file:

  • IntradayLogoutTolerance = true;
  • ForceSeqNumReset = 1

FIX Antenna will send only first Logon with ResetSeqNum flag (141=Y), after that it will always use the same set of logs and will reset sequence numbers only after logs cleanup.

How to reset sequence numbers manually?

In order to forcefully set sequence numbers to the expected values need to use Session::InSeqNum and Session::OutSeqNum properties.

What is the recommended way to recover when sequence numbers become out of sync?

Gap fill is a standard FIX mechanism for identifying and resolving message loss. It is based on sequencing messages in each direction, resend request mechanism, PossDup flag (43) and sequence reset.

  • When the session identifies a "sequence number is too high" problem it sends a resend request message asking for retransmission of lost messages. The opposite side resends requested messages with PossDupFlag set to "Y". Session level messages are not resent. The sequence reset is used to keep sequence numbers consistent during resending i.e. it is sent instead of session level messages or when messages to be resent are absent. The sequence reset gap fill message is used to skip a set of messages, it informs counterparty what sequence number to expect next. FIX Antenna resolves the gap fill automatically, i.e. no manual work is required. 
  • If incoming/outgoing sequence are too low ("sequence number is too low"), which indicates serious error, manual intervention is required. In this case Session.InSeqNum/OutSeqNum  properties should be corrected.

    For Unregistered Acceptors IgnoreSeqNumTooLowAtLogon property can be apllied. When it set to 'true' then the session ignores corresponding "sequence number is too low" error and continues to work with received sequence number

  • No labels