Session States
During the FIX session lifetime it could be in one of the following states:
State | Session-Acceptor | Session-Initiator |
---|---|---|
Disconnected | The session is disconnected | The session is disconnected |
AwaitLogon | The session is waiting for the initial Logon message | Not applicable (Initiator cannot be in this state) |
AwaitConfirmingLogon | Not applicable (Acceptor cannot be in this state) | The initial Logon message was sent and the session is waiting for the acknowledgment Logon message |
Established | The session is fully established (after the successful Logon exchange) | The session is fully established (after the successful Logon exchange) |
Reconnecting | Not applicable (Acceptor cannot be in this state) | Session is trying to restore the telecommunication link |
WaitForRetransmission | A message gap occurred, and the session waits for resent messages/gap fills | A message gap occurred, and the session waits for resent messages/gap fills |
AwaitConfirmingLogout | The initial Logout message was sent, the session is waiting for the acknowledgment Logout message | The initial Logout message was sent, the session is waiting for the acknowledgment Logout message |
The State property could be used to check the session's current state.
Initiator Session State Diagram
Acceptor Session State Diagram
Tracking Session State Changes
The Session class exposes the StateChanged event. Subscribing to this event provides the ability to be notified about all changes in the state of the source session.
For example:
var session = new Session("SenderCompID", "TargetCompID", ProtocolVersion.Fix44);
session.StateChanged += OnStateChanged;
void OnStateChanged(object sender, SessionStateChangeEventArgs e)
{
Console.WriteLine("Session {0} changed its state from {1} to {2}.", sender, e.PrevState, e.NewState);
}