DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk4 min

FIX Session Layer in C#: Logon, Heartbeats, Sequence Numbers and Resend

A practical guide to implementing FIX session behavior in C#: choose the agreed profile, keep session state separate from business messages, and handle heartbeats and recovery according to the applicable rules.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The FIX session layer governs technical communication between counterparties: keeping a connection active, tracking message sequence numbers, and recovering from gaps. The FIX application layer carries business messages such as orders and executions. In C#, implement these as related but distinct concerns, and confirm the governing session profile and bilateral rules before coding Logon, reset, or recovery behavior.

What the FIX session layer does

FIX is a family of standards with separate application, encoding, and session concerns. The application layer defines business-related message content; the session protocol defines technical interaction and delivery between counterparties. A session engine therefore needs to manage session state around the application messages it transports, rather than treating every incoming message as a business event.

As an Amazon Associate I earn from qualifying purchases.

The FIX Trading Community’s June 2020 session-protocol announcement describes the refactored session specification as the normative reference for session protocols. Its FIX Latest application-layer material is a separate specification, identified as EP284 from November 2023. “FIX Latest” application messages should not be mistaken for a session protocol version.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the session profile before implementing Logon or recovery

FIX behavior depends on the profile agreed with the counterparty. The FIX Trading Community identifies FIX.4.2, FIX4, FIXT, and LFIXT profiles. FIXT, introduced with FIX 5.0, is application-version independent, so it can support multiple application versions. The cited announcement does not establish that any one profile is universally preferable.

Profile Application-version support What to confirm
FIX.4.2 Not stated by the June 2020 FIX session-protocol announcement. Confirm that both counterparties have agreed to this profile and identify its applicable session and recovery rules.
FIX4 Not stated by the June 2020 FIX session-protocol announcement. Confirm that both counterparties have agreed to this profile and identify its applicable session and recovery rules.
FIXT Application-version independent; supports multiple application versions. Confirm the selected application version as well as the agreed FIXT session and recovery rules.
LFIXT Not stated by the June 2020 FIX session-protocol announcement. Confirm that both counterparties have agreed to this profile and identify its applicable session and recovery rules.

FIXP is a distinct performance-oriented session protocol, not an interchangeable name for the FIX session behavior discussed here. The FIX Trading Community describes FIXP as supporting recoverable, unsequenced, and idempotent modes. Use it only where the counterparties have chosen that protocol.

Logon and sequence initialization

Establish the session under the selected profile and the counterparty’s configuration. Maintain inbound and outbound sequence state, and apply reset semantics only when the governing profile and bilateral agreement permit them. The June 2020 session-protocol announcement identifies the profiles but does not, by itself, establish a universal Logon handshake, required fields, reset timing, or a rule to reset sequence numbers every 24 hours.

For a C# implementation, make Logon and sequence initialization explicit session-engine responsibilities. Treat a request to reset sequence state as a profile- and configuration-dependent decision, not as a generic convenience action. Verify the exact handshake and reset conditions in the normative specification for the selected profile and the counterparty’s session specification.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Heartbeats and TestRequest

Heartbeat (35=0) keeps a FIX connection active during periods of inactivity and is also sent in response to a peer’s TestRequest (35=1). A TestRequest forces a response from the peer. Its sender supplies TestReqID (112), which must be returned in the response Heartbeat; that echoed identifier links the reply to the request and confirms that the peer’s session response arrived.

A session engine can represent this behavior behind a small internal interface:

// Illustrative session-handler logic; not a complete FIX engine or wire encoder.
void OnTestRequest(string testReqId)
{
    session.SendHeartbeat(testReqId); // Include the received TestReqID (112).
}

The method shown is an implementation sketch, not a library API or full FIX message construction. Let the session engine assign and manage the outgoing message’s sequence number and encoding. The cited specification excerpts do not establish a particular heartbeat interval, timeout, reconnect policy, or scheduling mechanism; configure those according to the selected profile and counterparty agreement. The FIX Latest TestRequest reference also describes it as a way to force a Heartbeat and check sequence numbers or communication-line status.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Sequence numbers, ResendRequest, and recovery

ResendRequest (35=2) asks the peer to retransmit messages over a sequence-number range. BeginSeqNo (7) is the first requested number; EndSeqNo (16) is the last. An EndSeqNo of 0 means request all messages from BeginSeqNo onward. The FIX Session Layer standard describes the request as initiated by the receiving application to begin retransmission.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In C#, keep sequence tracking in the session layer: it needs to compare inbound messages with the expected inbound sequence and maintain outbound sequence state. A ResendRequest expresses a requested range; it does not, on its own, specify the complete replay algorithm or mean every requested message must be resent as its original application message.

Keep gap fills distinct from ordinary retransmission

SequenceReset gap fills are a recognized session-protocol behavior, but they are not a generic substitute for retransmission. Which messages to replay, when a gap fill is appropriate, and how expected sequence numbers advance depend on the selected profile and peer agreement. Check those rules in the current normative specification for that profile and in the counterparty’s agreed behavior before implementing recovery.

A practical C# implementation checklist

  • Pin down the profile: record the agreed session profile and, where relevant, the application version.
  • Separate responsibilities: keep session state, sequence tracking, Logon, heartbeat handling, and recovery distinct from business-message processing.
  • Correlate TestRequest replies: return the received TestReqID (112) in the response Heartbeat.
  • Handle resend ranges literally: use BeginSeqNo (7) and EndSeqNo (16), interpreting EndSeqNo=0 as open-ended from BeginSeqNo onward.
  • Apply recovery rules by profile: implement replay, SequenceReset gap fills, and sequence advancement according to the normative profile and bilateral configuration.
  • Make configuration explicit: keep intervals, reset behavior, and other peer-specific mechanics configurable rather than presenting them as universal FIX defaults.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.