• Version 1.15.2
Show / Hide Table of Contents

Class Session

A FIX Session. It is defined as a bi-directional stream of ordered messages between two parties within a continuous sequence number series. A single FIX session can exist across multiple sequential (not concurrent) physical connections. A FIX Connection is comprised of three parts: logon, message exchange, and logout. A FIX Session is comprised of one or more FIX Connections, meaning that a FIX Session spans multiple logins. Parties can connect and disconnect multiple times while maintaining a single FIX session. Connecting parties must bi-laterally agree as to when sessions are to be started/stopped based upon individual system and time zone requirements. Resetting the inbound and outbound sequence numbers back to 1, for whatever reason, constitutes the beginning of a new FIX session.

Inheritance
object
Session
Implements
ISession
IDisposable
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
Namespace: OnixS.Fix
Assembly: OnixS.Fix.Engine.dll
Syntax
public class Session : ISession, IDisposable

Constructors

Session(string, string, IMessageInfoDictionary, bool, SessionStorageType, string)

Creates the FIX session.

Declaration
public Session(string senderCompId, string targetCompId, IMessageInfoDictionary dictionary, bool keepSequenceNumbersBetweenFixConnections = true, SessionStorageType storageType = SessionStorageType.FileBasedStorage, string customKey = "")
Parameters
Type Name Description
string senderCompId

Assigned value used to identify firm sending message (the SenderCompID (tag=49) field value in outgoing messages)

string targetCompId

Assigned value used to identify receiving firm (the TargetCompID (tag=56) field value in outgoing messages)

IMessageInfoDictionary dictionary

FIX dictionary

bool keepSequenceNumbersBetweenFixConnections

Option to keep sequence numbers after the exchange of Logout (MsgType=5) messages

SessionStorageType storageType

Session's storage type.

string customKey

Custom key that can be used to distinguish sessions with the same values of the SenderCompID, TargetCompID and the FIX Protocol version.

Session(string, string, IMessageInfoDictionary, bool, ISessionStorage, string)

Creates the FIX session.

Declaration
public Session(string senderCompId, string targetCompId, IMessageInfoDictionary dictionary, bool keepSequenceNumbersBetweenFixConnections, ISessionStorage sessionStorage, string customKey = "")
Parameters
Type Name Description
string senderCompId

Assigned value used to identify firm sending message (the SenderCompID (tag=49) field value in outgoing messages)

string targetCompId

Assigned value used to identify receiving firm (the TargetCompID (tag=56) field value in outgoing messages)

IMessageInfoDictionary dictionary

FIX dictionary

bool keepSequenceNumbersBetweenFixConnections

Option to keep sequence numbers after the exchange of Logout (MsgType=5) messages

ISessionStorage sessionStorage
string customKey

Custom key that can be used to distinguish sessions with the same values of the SenderCompID, TargetCompID and the FIX Protocol version.

Session(string, string, ProtocolVersion, bool, SessionStorageType, string)

Creates the FIX session.

Declaration
public Session(string senderCompId, string targetCompId, ProtocolVersion version, bool keepSequenceNumbersBetweenFixConnections = true, SessionStorageType storageType = SessionStorageType.FileBasedStorage, string customKey = "")
Parameters
Type Name Description
string senderCompId

Assigned value used to identify firm sending message (the SenderCompID (tag=49) field value in outgoing messages)

string targetCompId

Assigned value used to identify receiving firm (the TargetCompID (tag=56) field value in outgoing messages)

ProtocolVersion version

FIX Protocol version

bool keepSequenceNumbersBetweenFixConnections

Option to keep sequence numbers after the exchange of Logout (MsgType=5) messages

SessionStorageType storageType

Session's storage type.

string customKey

Custom key that can be used to distinguish sessions with the same values of the SenderCompID, TargetCompID and the FIX Protocol version.

Session(string, string, ProtocolVersion, bool, ISessionStorage, string)

Creates the FIX session.

Declaration
public Session(string senderCompId, string targetCompId, ProtocolVersion version, bool keepSequenceNumbersBetweenFixConnections, ISessionStorage sessionStorage, string customKey = "")
Parameters
Type Name Description
string senderCompId

Assigned value used to identify firm sending message (the SenderCompID (tag=49) field value in outgoing messages)

string targetCompId

Assigned value used to identify receiving firm (the TargetCompID (tag=56) field value in outgoing messages)

ProtocolVersion version

FIX Protocol version

bool keepSequenceNumbersBetweenFixConnections

Option to keep sequence numbers after the exchange of Logout (MsgType=5) messages

ISessionStorage sessionStorage
string customKey

Custom key that can be used to distinguish sessions with the same values of the SenderCompID, TargetCompID and the FIX Protocol version.

Fields

DefaultHeartBeatIntervalSeconds

Default Heartbeat Interval (seconds).

Declaration
public const int DefaultHeartBeatIntervalSeconds = 30
Field Value
Type Description
int

ResendRequestMaximumRangeNoLimit

Represents the unlimited number of messages to be requested in one Resend Request (MsgType=2) message.

Declaration
public const int ResendRequestMaximumRangeNoLimit = 0
Field Value
Type Description
int

The unlimited number of messages to be requested in one Resend Request (MsgType=2) message

Properties

ConsiderRejectOnResendRequestAsGapFill

By default if the "Session Level Reject" message is received in replay to the "Resend Request" then this is considered as a serious problem and the FIX connection will be closed. This property allows to change this behavior and consider the "Session Level Reject" on the "Resend Request" as the "Sequence Reset Gap Fill" message.

Declaration
public bool ConsiderRejectOnResendRequestAsGapFill { get; set; }
Property Value
Type Description
bool

Consider the "Session Level Reject" on the "Resend Request" as the "Sequence Reset Gap Fill" message

CounterpartyHost

Counterparty host name.

Declaration
public string CounterpartyHost { get; }
Property Value
Type Description
string

Counterparty host name

CounterpartyIpAddress

Counterparty IP address.

Declaration
public IPAddress CounterpartyIpAddress { get; }
Property Value
Type Description
IPAddress

Counterparty IP address

CounterpartyPort

Counterparty port number.

Declaration
public int CounterpartyPort { get; }
Property Value
Type Description
int

Counterparty port

CreationTime

The time when the session instance was created or the last local reset of sequence numbers was performed.

Declaration
public DateTime CreationTime { get; }
Property Value
Type Description
DateTime

Session's creation time

CustomKey

Custom key that can be used to distinguish sessions with the same values of the SenderCompID, TargetCompID and the FIX Protocol version.

Declaration
public string CustomKey { get; }
Property Value
Type Description
string

Custom key

Dictionary

Session's Dictionary.

Declaration
public IMessageInfoDictionary Dictionary { get; }
Property Value
Type Description
IMessageInfoDictionary

Session's Dictionary

Encryption

Connection encryption method.

Declaration
public EncryptionMethod Encryption { get; set; }
Property Value
Type Description
EncryptionMethod

Engine

Declaration
public Engine Engine { get; }
Property Value
Type Description
Engine

HeartBtInt

Gets the Heartbeat interval (seconds, HeartBtInt, tag=108 field value).

Declaration
public int HeartBtInt { get; }
Property Value
Type Description
int

The Heartbeat interval (seconds, HeartBtInt, tag=108 field value).

HeartbeatResolution

Heartbeat resolution in milliseconds.

Note: This property should be used only to speed up heartbeat-related Unit Tests.

Declaration
public int HeartbeatResolution { get; set; }
Property Value
Type Description
int

Heartbeat resolution in milliseconds

IgnoreLessThanExpectedSequenceNumber

By default if the incoming message has a sequence number less than expected and the PossDupFlag is not set, it indicates a serious error and leads to FIX connection closing. This property allows to change this behavior and consider the sequence number of the incoming message, which less than expected, as an expected one.

Declaration
public bool IgnoreLessThanExpectedSequenceNumber { get; set; }
Property Value
Type Description
bool

InSeqNum

The expected sequence number of the next incoming message.

Declaration
public int InSeqNum { get; set; }
Property Value
Type Description
int

The expected sequence number of the next incoming message.

InboundMessageLogFilter

Incoming message types to be filtered out from the logs.

Declaration
public string[] InboundMessageLogFilter { get; set; }
Property Value
Type Description
string[]

Incoming message types to be filtered out from the logs.

IncomingMessageGapQueueMaximumSize

Returns maximum size of the incoming message gap queue.

Declaration
public int IncomingMessageGapQueueMaximumSize { get; set; }
Property Value
Type Description
int

maximum size of the incoming message gap queue.

IsDisposed

Gets a value indicating whether the Session has been disposed of.

Declaration
public bool IsDisposed { get; }
Property Value
Type Description
bool

true if the Session has been disposed of; otherwise, false.

KeepSequenceNumbersBetweenFixConnections

Option to keep sequence numbers after the exchange of Logout (MsgType=5) messages. By default the value is true.

Declaration
public bool KeepSequenceNumbersBetweenFixConnections { get; set; }
Property Value
Type Description
bool

whether to keep sequence numbers after the exchange of Logout (MsgType=5) messages

ListenPort

Port to listen on for incoming connections in Acceptor mode.

Declaration
public int ListenPort { get; set; }
Property Value
Type Description
int

Port to listen on for incoming connections in Acceptor mode

LocalNetworkInterface

The network interface for establishing the TCP connection as an Initiator.

The default value is LocalNetworkInterface.

Declaration
public IPAddress LocalNetworkInterface { get; set; }
Property Value
Type Description
IPAddress

The network interface for establishing the TCP connection as an Initiator

LocalPort

Returns the local port that is used by the outgoing connection.

Declaration
public int LocalPort { get; }
Property Value
Type Description
int

Local ports

See Also
LocalPortRange

LocalPortRange

The local port range for outgoing connections, the first available port from this range will be used to send and receive data.

By default, a random port will be used.

Declaration
public PortRange LocalPortRange { get; set; }
Property Value
Type Description
PortRange

Local port range.

LogBeforeSending

Option to switch on/off logging of outbound messages before/after sending.

By default, the logging of an outgoing message to the session storage is performed before sending to the wire. This is more reliable because we guarantee that an outgoing message is stored before going to the counterparty and if the application is shut down after sending, for some reasons, the sent message can be resent afterward.

However, this approach adds the logging latency to the FIX Engine sending latency. As a result, it increases the tick-to-trade latency. When the latency is more important, one can switch off the logging before sending, by setting the OnixS::FIX::Session::logBeforeSending option to false. In this case, the logging of outgoing messages to the session storage will be performed after sending to the wire. This way, one can exclude the logging latency from the FIX Engine sending latency and as a result, decrease the tick-to-trade latency.

Declaration
public bool LogBeforeSending { get; set; }
Property Value
Type Description
bool

LogInboundMessages

Store inbound messages in the session storage.

The default value is LogInboundMessages.

Declaration
public bool LogInboundMessages { get; set; }
Property Value
Type Description
bool

Store inbound messages in the session value

LogOutboundMessages

Store outbound messages in the session storage.

/// The default value is LogOutboundMessages.

Declaration
public bool LogOutboundMessages { get; set; }
Property Value
Type Description
bool

Store outbound messages in the session storage

LogonTimeout

Number of seconds to wait for a logon response before disconnecting.

/// The default value is LogonTimeout.

Declaration
public int LogonTimeout { get; set; }
Property Value
Type Description
int

Number of seconds to wait for a logon response before disconnecting

LogoutTimeout

Number of seconds to wait for a logout response before disconnecting.

/// The default value is LogoutTimeout.

Declaration
public int LogoutTimeout { get; set; }
Property Value
Type Description
int

Number of seconds to wait for a logout response before disconnecting

MemoryPoolSettings

Settings of memory pool for the reused inbound message.

Declaration
public MessageMemoryPoolSettings MemoryPoolSettings { get; }
Property Value
Type Description
MessageMemoryPoolSettings

MessageGrouping

Message sending grouping.

The default value is MessageGrouping.

Declaration
public int MessageGrouping { get; set; }
Property Value
Type Description
int

Value 0 means the default grouping - the messages will be sent ASAP and pending messages (if any) will be grouped until reaching the TCP buffer size. Value 1 means the messages will be sent ASAP and will never be grouped. Value 2 (or greater) means the messages will be sent ASAP and pending messages will be grouped maximum by 2 (or greater).

MessageMode

Type of messages to be used in Session's events.

The default value is Message.

Declaration
public MessageMode MessageMode { get; set; }
Property Value
Type Description
MessageMode

Type of messages to be used in Session's events

OutSeqNum

The sequence number of the next outgoing message.

Declaration
public int OutSeqNum { get; set; }
Property Value
Type Description
int

the sequence number of the next outgoing message

OutboundMessageLogFilter

Outgoing message types to be filtered out from the logs.

Declaration
public string[] OutboundMessageLogFilter { get; set; }
Property Value
Type Description
string[]

Outgoing message types to be filtered out from the logs.

OutboundQueueBytes

Returns the total size of messages in the outgoing queue in bytes.

Declaration
public ulong OutboundQueueBytes { get; }
Property Value
Type Description
ulong

the total size of messages in bytes

Proxy

Proxy settings.

Declaration
public ProxySettings Proxy { get; }
Property Value
Type Description
ProxySettings

ReasonableTransmissionTime

Reasonable transmission time as % from the heartbeat interval.

The default value is ReasonableTransmissionTime.

Declaration
public int ReasonableTransmissionTime { get; set; }
Property Value
Type Description
int

Reasonable transmission time as % from the heartbeat interval

ReceiveBufferSize

Size of the TCP socket buffer allocated for receiving data, in bytes.

Declaration
public int ReceiveBufferSize { get; set; }
Property Value
Type Description
int

ReceiveSpinningTimeout

The non-blocking receive spinning timeout (in microseconds) before the receiving thread enters into the blocking wait mode.

Should not be greater than 1 sec. (the minimal HeartbeatInterval interval).

The default value is ReceiveSpinningTimeout.

Declaration
public int ReceiveSpinningTimeout { get; set; }
Property Value
Type Description
int

Receive spinning timeout (in microseconds)

ReceivingThreadAffinity

Receiving thread affinity.

Declaration
public int[] ReceivingThreadAffinity { get; set; }
Property Value
Type Description
int[]

ReceivingThreadPriority

Gets or sets the priority of the session receiving thread.

The default value is set by OS.

Declaration
public ThreadPriority ReceivingThreadPriority { get; set; }
Property Value
Type Description
ThreadPriority

The priority of the session receiving thread

ReconnectAttempts

Number of attempts to restore the FIX connection.

The default value is ReconnectAttempts.

Declaration
public int ReconnectAttempts { get; set; }
Property Value
Type Description
int

Number of attempts to restore the FIX connection

ReconnectInterval

Time interval between attempts to restore the FIX connection (in seconds).

The default value is ReconnectInterval.

Declaration
public int ReconnectInterval { get; set; }
Property Value
Type Description
int

Time interval between attempts to restore the FIX connection (in seconds)

ReportNewMessagesWhileWaitingForMissedMessages

When the message gap is detected the "Resend Request" FIX Message is sent and Session state is changed to WaitForRetransmission. By default in this state the incoming new messages (without the PossDupFlag (tag #43) flag) are ignored because we expect them to be re-sent later again with the PossDupFlag flag. This property allows to change this behavior and report the new messages anyway.

Note: In this mode messages could be reported out of the original order: e.g. MsgSeqNum could be: 3 (original), 4 (original), 2 (PossDupFlag='Y'), 3 (PossDupFlag='Y'), 4 (PossDupFlag='Y') and some messages could be received two times: first time without PossDupFlag='Y' and second time - with this flag.

Default value is false.
Declaration
public bool ReportNewMessagesWhileWaitingForMissedMessages { get; set; }
Property Value
Type Description
bool

Report new messages even when the message gap is detected and the reply on the "Resend Request" message is expected.

RequestOnlyMissedMessages

By default, the "Resend Request" message requests all messages beginning from the first missed one. This property allows to change this behavior and request only missed messages.

The default is false.

Declaration
public bool RequestOnlyMissedMessages { get; set; }
Property Value
Type Description
bool

Request only missed messages

ResendRequestMaximumRange

The maximum number of messages to be requested in one Resend Request(2) message.

The default value is ResendRequestMaximumRange.

Declaration
public int ResendRequestMaximumRange { get; set; }
Property Value
Type Description
int

The maximum number of messages to be requested in one Resend Request (MsgType=2) message or ResendRequestMaximumRangeNoLimit for no limit

ResendTimeout

The timeout during which counterparty should send a reply to the Resend Request (MsgType=2) message. If a counterparty does not reply or reply incorrectly during this timeout, then the Warning is called. By default, the resend request timeout equal to zero, which means an infinite timeout.

Declaration
public TimeSpan ResendTimeout { get; set; }
Property Value
Type Description
TimeSpan

The timeout during which counterparty should send a reply to the Resend Request (MsgType=2) message.

ResendingBatchSize

The maximum number of messages sent in reply to the Resend Request(2) before temporarily releasing the Session’s lock.

The default value is ResendingBatchSize.

Declaration
public int ResendingBatchSize { get; set; }
Property Value
Type Description
int

The maximum number of messages sent in reply to the Resend Request(2) before temporarily releasing the Session’s lock

ResendingQueueSize

The number of sent messages that are available for resending in reply to the counterparty's "Resend Request" message.

The default value is ResendingQueueSize.

Declaration
public int ResendingQueueSize { get; set; }
Property Value
Type Description
int

The number of sent messages that are available for resending in reply to the counterparty's "Resend Request" message

ResetLocalSequenceNumbersOnLogon

Option to automatically reset the local sequence numbers to 1 during every logon. The default is the opposite value of keepSequenceNumbersBetweenFixConnections session constructor's parameter.

Declaration
public bool ResetLocalSequenceNumbersOnLogon { get; set; }
Property Value
Type Description
bool

whether to automatically reset the local sequence numbers to 1 during every logon

ReuseEventArguments

Reuse event arguments.

Note: If it is turned on, then the client code must copy event arguments for using outside of event handlers.

The default value is false.

Declaration
public bool ReuseEventArguments { get; set; }
Property Value
Type Description
bool

Reuse event arguments

ReuseInboundMessage

Reuse the same Message object for incoming messages.

Note: If it is turned on, then the client code must copy the Message object for using outside of inbound event handlers.

The default value is false.

Declaration
public bool ReuseInboundMessage { get; set; }
Property Value
Type Description
bool

Reuse the same Message object for incoming messages.

Role

Session's role.

Declaration
public SessionRole Role { get; }
Property Value
Type Description
SessionRole

Session's role

ScrambledLogonFields

Tags for the Logon(A) message fields to scramble in the session storage for security reasons.

Declaration
public Collection<int> ScrambledLogonFields { get; set; }
Property Value
Type Description
Collection<int>

SendBufferSize

Size of the TCP socket buffer allocated for sending data, in bytes.

Declaration
public int SendBufferSize { get; set; }
Property Value
Type Description
int

SendLogoutOnException

Send the Logout message before dropping the telecommunication link in case of an exception during the processing of an incoming FIX message.

The default value is SendLogoutOnException.

Declaration
public bool SendLogoutOnException { get; set; }
Property Value
Type Description
bool

option to send or not to send

SendQueueMaxSize

Send queue maximum size in bytes.

The default value is SendQueueMaxSize.

Declaration
public int SendQueueMaxSize { get; set; }
Property Value
Type Description
int

Send queue maximum size in bytes

SendResendRequestOnEachMessageGap

By default the "Resend Request" message is sent only once - when the first gap is detected. This property allows to send the "Resend Request" message on each detected message sequence number gap.

Declaration
public bool SendResendRequestOnEachMessageGap { get; set; }
Property Value
Type Description
bool

Send the "Resend Request" message on each detected message sequence number gap

SendSpinningTimeout

The send spinning timeout (in microseconds) of the Send(IMessage) method to wait for the socket sending buffer availability in the spin loop mode before placing the message to the outgoing queue (to be sent later by the sending thread).

Should not be greater than 1 sec (the minimal Heartbeat interval).

The default value is SendSpinningTimeout.

Declaration
public int SendSpinningTimeout { get; set; }
Property Value
Type Description
int

The send spinning timeout (in microseconds)

SenderCompId

Assigned value used to identify firm sending message (the SenderCompID (tag 49) field value in outgoing messages).

Declaration
public string SenderCompId { get; }
Property Value
Type Description
string

SenderCompID (tag 49) field value

SenderLocationId

The value of the SenderLocationID (tag 142) field that will be set in all outgoing messages.

Declaration
public string SenderLocationId { get; set; }
Property Value
Type Description
string

SenderLocationID (tag 142) field value.

SenderSubId

The value of the SenderSubID (tag 50) field that will be set in all outgoing messages.

Declaration
public string SenderSubId { get; set; }
Property Value
Type Description
string

SenderSubID (tag 50) field value.

SendingThreadAffinity

Sending thread affinity.

Declaration
public int[] SendingThreadAffinity { get; set; }
Property Value
Type Description
int[]

SendingThreadPriority

Gets or sets the priority of the session sending thread.

The default value is set by OS.

Declaration
public ThreadPriority SendingThreadPriority { get; set; }
Property Value
Type Description
ThreadPriority

The priority of the session sending thread

SendingTimeFormat

Sets the time format of SendingTime of every sent message. By default, the YYYYMMDDHHMMSSMsec format is used.

Declaration
public TimestampFormat SendingTimeFormat { set; }
Property Value
Type Description
TimestampFormat

The time format of the SendingTime (52) field

SetApplId

Option to set the ApplVerID (1128) field in all outgoing application messages when a FIX protocol version FIX 5.0 or above is used.

The default value is SetApplVerId.

Declaration
public bool SetApplId { get; set; }
Property Value
Type Description
bool

Set the ApplVerID (1128) field in all outgoing application messages when a FIX protocol version FIX 5.0 or above is used

SetLastMsgSeqNumProcessed

Option to set the LastMsgSeqNumProcessed(369) field in outgoing messages.

The default value is SetLastMsgSeqNumProcessed.

Declaration
public bool SetLastMsgSeqNumProcessed { get; set; }
Property Value
Type Description
bool

Set the LastMsgSeqNumProcessed(369) field in outgoing messages

Ssl

SSL connection settings.

Declaration
public SslSettings Ssl { get; }
Property Value
Type Description
SslSettings

State

Session's state.

Declaration
public SessionState State { get; }
Property Value
Type Description
SessionState

Session's state

StorageDirectory

Inbound and outbound FIX messages and session's state data are stored in this directory.

The default value is StorageDirectory.

Declaration
public string StorageDirectory { get; set; }
Property Value
Type Description
string

Storage directory

StorageId

The Id of the session storage.

Declaration
public string StorageId { get; }
Property Value
Type Description
string

Session storage id

StorageType

Session's storage type.

Declaration
public SessionStorageType StorageType { get; }
Property Value
Type Description
SessionStorageType

Session's storage type.

SupportNextExpectedMsgSeqNum

Option to support the NextExpectedMsgSeqNum field (tag 789) in Logon (MsgType=A) messages.

Note: Using of this option should be bilaterally agreed upon between counterparts.

The default value is SupportNextExpectedMsgSeqNum.

Declaration
public bool SupportNextExpectedMsgSeqNum { get; set; }
Property Value
Type Description
bool

Support the NextExpectedMsgSeqNum field (tag 789) in Logon (MsgType=A) messages

TargetCompId

Assigned value used to identify receiving firm (the TargetCompID (tag 56) field value in outgoing messages).

Declaration
public string TargetCompId { get; }
Property Value
Type Description
string

TargetCompID (tag 56) field Value

TargetLocationId

The value of TargetLocationID (tag 143) field that will be set in all outgoing messages.

Declaration
public string TargetLocationId { get; set; }
Property Value
Type Description
string

TargetLocationID (tag 143) field value.

TargetSubId

The value of the TargetSubID (tag 57) field that will be set in all outgoing messages.

Declaration
public string TargetSubId { get; set; }
Property Value
Type Description
string

TargetSubID (tag 57) field value.

TcpNoDelay

Improve latency at the expense of throughput (disable/enable Nagle's algorithm).

The default value is TcpNoDelay.

Declaration
public bool TcpNoDelay { get; set; }
Property Value
Type Description
bool

Improve latency at the expense of throughput (disable/enable Nagle's algorithm)

UpdateSendingTime

Option to update the SendingTime (52) field in the outgoing message even if it is already set.

The default value is UpdateSendingTime.

Declaration
public bool UpdateSendingTime { get; set; }
Property Value
Type Description
bool

Update the SendingTime (52) field in the outgoing message if it is already set

ValidateCheckSum

Validate the CheckSum (tag 10) field value.

The default value is ValidateCheckSum.

Declaration
public bool ValidateCheckSum { get; set; }
Property Value
Type Description
bool

Validate the CheckSum (tag 10) field value

ValidateDuplicatedFields

Option to validate the presence of fields that appears more than once.

The default value is ValidateDuplicatedFields.

Declaration
public bool ValidateDuplicatedFields { get; set; }
Property Value
Type Description
bool

Validate the presence of fields that appears more than once

ValidateEmptyFieldValues

Option to validate empty message field values.

The default value is ValidateEmptyFieldValues.

Declaration
public bool ValidateEmptyFieldValues { get; set; }
Property Value
Type Description
bool

Validate empty message field values

ValidateFieldValues

Option to validate field values of FIX messages in accordance with the FIX protocol or its FIX Dialect.

The default value is ValidateFieldValues.

Declaration
public bool ValidateFieldValues { get; set; }
Property Value
Type Description
bool

Validate message field values

ValidateRepeatingGroupEntryCount

Option to validate that the declared number of repeating group instances is equal to the actual one.

The default value is ValidateRepeatingGroupEntryCount.

Declaration
public bool ValidateRepeatingGroupEntryCount { get; set; }
Property Value
Type Description
bool

Validate that the declared number of repeating group instances is equal to the actual one

ValidateRepeatingGroupLeadingField

Validate that repeating group instances start with the correct leading fields.

The default value is ValidateRepeatingGroupLeadingField.

Declaration
public bool ValidateRepeatingGroupLeadingField { get; set; }
Property Value
Type Description
bool

Validate that repeating group instances start with the correct leading fields.

ValidateRequiredFields

Validate the presence of required fields.

The default value is ValidateRequiredFields.

Declaration
public bool ValidateRequiredFields { get; set; }
Property Value
Type Description
bool

Validate the presence of required fields

ValidateSequenceNumbers

Returns whether to validate incoming message sequence numbers. Default value is true.

Declaration
public bool ValidateSequenceNumbers { get; set; }
Property Value
Type Description
bool

whether to validate incoming message sequence numbers

ValidateUnknownFields

Validate that there are no unknown message fields.

The default value is ValidateUnknownFields.

Declaration
public bool ValidateUnknownFields { get; set; }
Property Value
Type Description
bool

Validate that there are no unknown message fields.

ValidateUnknownMessages

Validate that there are no unknown messages received.

The default value is ValidateUnknownMessages.

Declaration
public bool ValidateUnknownMessages { get; set; }
Property Value
Type Description
bool

Validate that there are no unknown messages received.

Version

Returns the FIX Protocol version.

Declaration
public ProtocolVersion Version { get; }
Property Value
Type Description
ProtocolVersion

FIX version

Methods

BreakConnection(bool)

Breaks the FIX connection non-gracefully (without the exchange of Logout (MsgType=5) messages).

Declaration
public ISession BreakConnection(bool async = false)
Parameters
Type Name Description
bool async

If false then the method blocks until the TCP connection is closed. If true then the method returns immediately.

Returns
Type Description
ISession

ClearOutboundQueue(bool)

Removes all messages from the outbound queue.

Declaration
public void ClearOutboundQueue(bool removeFragmentedPacket)
Parameters
Type Name Description
bool removeFragmentedPacket

Specifies whether to remove the last packet, which is partly sent.

Dispose()

Terminates the FIX Session, explicitly releases resource and removes the object from Garbage Collector.

Declaration
public void Dispose()

Dispose(bool)

Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type Name Description
bool disposing

~Session()

Perform cleanup operations on unmanaged resources held by the current Session object before the object is destroyed.

Declaration
protected ~Session()

FindSentMessage(int)

Finds the sent FIX message by the given message sequence number.

Declaration
public IMessage FindSentMessage(int sequenceNumber)
Parameters
Type Name Description
int sequenceNumber

Message sequence number

Returns
Type Description
IMessage

Found message or null if the message is not found

FlushSessionStorage()

Calls Flush() method of the session storage.

Declaration
public ISession FlushSessionStorage()
Returns
Type Description
ISession

LogonAsAcceptor()

Establishes FIX Connection as Acceptor.

Acceptor is the receiving party of the FIX session. It listens for the incoming connection on the pre-defined port. The acceptor has responsibility to perform first level authentication and formally declare the connection request "accepted" through transmission of an acknowledgment Logon message.

Declaration
public ISession LogonAsAcceptor()
Returns
Type Description
ISession

LogonAsInitiator(IPAddress, int, int, bool, IMessage, bool)

Establishes the FIX connection as Initiator.

Initiator establishes the telecommunications link and initiates the FIX connection via transmission of the initial Logon message.

Declaration
public ISession LogonAsInitiator(IPAddress address, int port, int heartBtInt = 30, bool setResetSeqNumFlagInFirstLogon = false, IMessage customLogonMessage = null, bool async = false)
Parameters
Type Name Description
IPAddress address

Counterparty's host Internet Protocol (IP) address

int port

Counterparty's port number

int heartBtInt

Heartbeat interval (seconds)

bool setResetSeqNumFlagInFirstLogon

Set the ResetSeqNumFlag (tag 141) in the initial Logon (MsgType=A) message

IMessage customLogonMessage

Custom Logon message

bool async

If false then the method blocks until the acknowledgment Logon message is received or the Heartbeat interval is elapsed. If true then the method returns immediately without waiting for the acknowledgment Logon message.

Returns
Type Description
ISession
Exceptions
Type Condition
CannotEstablishLinkException

The telecommunication link cannot be established

LinkErrorException

After sending the initial Logon message the telecommunication link error is detected

FirstMessageNotLogonException

The first received message is not a Logon

UnexpectedSequenceNumberException

The first received message has an unexpected sequence number

InvalidInboundLogonException

The first received message is an invalid Logon message

LogonReplyTimeoutException

After sending the initial Logon message the acknowledgment Logon message has not been received during the timeout period. The timeout is calculated using the heartbeat value.

LogonAsInitiator(string, int, int, bool, IMessage, bool)

Establishes the FIX connection as Initiator.

Initiator establishes the telecommunications link and initiates the FIX connection via transmission of the initial Logon message.

Declaration
public ISession LogonAsInitiator(string host, int port, int heartBtInt = 30, bool setResetSeqNumFlagInFirstLogon = false, IMessage customLogonMessage = null, bool async = false)
Parameters
Type Name Description
string host

Counterparty's host name or address

int port

Counterparty's port number

int heartBtInt

Heartbeat interval (seconds)

bool setResetSeqNumFlagInFirstLogon

Set the ResetSeqNumFlag (tag 141) in the initial Logon (MsgType=A) message

IMessage customLogonMessage

Custom Logon message

bool async

If false then the method blocks until the acknowledgment Logon message is received or the Heartbeat interval is elapsed. If true then the method returns immediately without waiting for the acknowledgment Logon message.

Returns
Type Description
ISession
Exceptions
Type Condition
CannotEstablishLinkException

The telecommunication link cannot be established

LinkErrorException

After sending the initial Logon message the telecommunication link error is detected

FirstMessageNotLogonException

The first received message is not a Logon

UnexpectedSequenceNumberException

The first received message has an unexpected sequence number

InvalidInboundLogonException

The first received message is an invalid Logon message

LogonReplyTimeoutException

After sending the initial Logon message the acknowledgment Logon message has not been received during the timeout period. The timeout is calculated using the heartbeat value.

LogonAsInitiatorAsync(IPAddress, int, int, bool, IMessage)

Establishes the FIX connection as Initiator.

Initiator establishes the telecommunications link and initiates the FIX connection via transmission of the initial Logon message.

Declaration
public Task LogonAsInitiatorAsync(IPAddress address, int port, int heartBtInt = 30, bool setResetSeqNumFlagInFirstLogon = false, IMessage customLogonMessage = null)
Parameters
Type Name Description
IPAddress address

Counterparty's host Internet Protocol (IP) address

int port

Counterparty's port number

int heartBtInt

Heartbeat interval (seconds)

bool setResetSeqNumFlagInFirstLogon

Set the ResetSeqNumFlag (tag 141) in the initial Logon (MsgType=A) message

IMessage customLogonMessage

Custom Logon message

Returns
Type Description
Task

A task that represents the asynchronous logon operation

Exceptions
Type Condition
CannotEstablishLinkException

The telecommunication link cannot be established

LinkErrorException

After sending the initial Logon message the telecommunication link error is detected

FirstMessageNotLogonException

The first received message is not a Logon

UnexpectedSequenceNumberException

The first received message has an unexpected sequence number

InvalidInboundLogonException

The first received message is an invalid Logon message

LogonReplyTimeoutException

After sending the initial Logon message the acknowledgment Logon message has not been received during the timeout period. The timeout is calculated using the heartbeat value.

LogonAsInitiatorAsync(string, int, int, bool, IMessage)

Establishes the FIX connection as Initiator.

Initiator establishes the telecommunications link and initiates the FIX connection via transmission of the initial Logon message.

Declaration
public Task LogonAsInitiatorAsync(string host, int port, int heartBtInt = 30, bool setResetSeqNumFlagInFirstLogon = false, IMessage customLogonMessage = null)
Parameters
Type Name Description
string host

Counterparty's host name or address

int port

Counterparty's port number

int heartBtInt

Heartbeat interval (seconds)

bool setResetSeqNumFlagInFirstLogon

Set the ResetSeqNumFlag (tag 141) in the initial Logon (MsgType=A) message

IMessage customLogonMessage

Custom Logon message

Returns
Type Description
Task

A task that represents the asynchronous logon operation

Exceptions
Type Condition
CannotEstablishLinkException

The telecommunication link cannot be established

LinkErrorException

After sending the initial Logon message the telecommunication link error is detected

FirstMessageNotLogonException

The first received message is not a Logon

UnexpectedSequenceNumberException

The first received message has an unexpected sequence number

InvalidInboundLogonException

The first received message is an invalid Logon message

LogonReplyTimeoutException

After sending the initial Logon message the acknowledgment Logon message has not been received during the timeout period. The timeout is calculated using the heartbeat value.

Logout(IMessage, bool)

Terminates the FIX connection.

The provided Logout message is sent to the counterparty.

Declaration
public ISession Logout(IMessage logoutMessage, bool async = false)
Parameters
Type Name Description
IMessage logoutMessage

The Logout message to be sent to the counterparty

bool async

If false then the method blocks until the acknowledgment Logout message is received or the Heartbeat interval is elapsed. If true then the method returns immediately without waiting for the acknowledgment Logout message.

Returns
Type Description
ISession

Logout(bool)

Terminates the FIX connection.

The initial Logout message is sent to the counterparty.

Declaration
public ISession Logout(bool async = false)
Parameters
Type Name Description
bool async

If false then the method blocks until the acknowledgment Logout message is received or the Heartbeat interval is elapsed. If true then the method returns immediately without waiting for the acknowledgment Logout message.

Returns
Type Description
ISession

Logout(string, bool)

Terminates the FIX connection.

The initial Logout message is sent to the counterparty.

Declaration
public ISession Logout(string text, bool async = false)
Parameters
Type Name Description
string text

Free format text string that is sent to the counterparty in the Text (tag=58) field of the initial Logout message

bool async

If false then the method blocks until the acknowledgment Logout message is received or the Heartbeat interval is elapsed. If true then the method returns immediately without waiting for the acknowledgment Logout message.

Returns
Type Description
ISession

LogoutAsync()

Terminates the FIX connection asynchronously.

The initial Logout message is sent to the counterparty.

Declaration
public Task LogoutAsync()
Returns
Type Description
Task

A task that represents the asynchronous logout operation

LogoutAsync(IMessage)

Terminates the FIX connection asynchronously.

The provided Logout message is sent to the counterparty.

Declaration
public Task LogoutAsync(IMessage logoutMessage)
Parameters
Type Name Description
IMessage logoutMessage

The Logout message to be sent to the counterparty

Returns
Type Description
Task

A task that represents the asynchronous logout operation

LogoutAsync(string)

Terminates the FIX connection asynchronously.

The initial Logout message is sent to the counterparty.

Declaration
public Task LogoutAsync(string text)
Parameters
Type Name Description
string text

Free format text string that is sent to the counterparty in the Text (tag=58) field of the initial Logout message

Returns
Type Description
Task

A task that represents the asynchronous logout operation

OnError(SessionErrorEventArgs)

Declaration
protected virtual void OnError(SessionErrorEventArgs e)
Parameters
Type Name Description
SessionErrorEventArgs e

OnStateChanged(EventHandler<SessionStateChangeEventArgs>, SessionStateChangeEventArgs)

Declaration
protected virtual void OnStateChanged(EventHandler<SessionStateChangeEventArgs> eventHandler, SessionStateChangeEventArgs e)
Parameters
Type Name Description
EventHandler<SessionStateChangeEventArgs> eventHandler
SessionStateChangeEventArgs e

OnWarning(SessionWarningEventArgs)

Declaration
protected virtual void OnWarning(SessionWarningEventArgs e)
Parameters
Type Name Description
SessionWarningEventArgs e

PreFill(IMessage)

Pre-fills session-level fields that are constant during the session's lifetime: SenderCompId, TargetCompId, SenderLocationId, TargetLocationID, SenderSubID, TargetSubID.

Declaration
public ISession PreFill(IMessage message)
Parameters
Type Name Description
IMessage message

Message to pre-fill

Returns
Type Description
ISession

PreFill(SerializedMessage)

Pre-fills session-level fields that are constant during the session's lifetime: SenderCompId, TargetCompId, SenderLocationId, TargetLocationID, SenderSubID, TargetSubID.

Declaration
public ISession PreFill(SerializedMessage message)
Parameters
Type Name Description
SerializedMessage message

Message to pre-fill

Returns
Type Description
ISession

ResetLocalSequenceNumbers()

Resets the local sequence numbers to 1 and backups the current log files.

NOTE: This method can be called only when the session is disconnected.

Declaration
public ISession ResetLocalSequenceNumbers()
Returns
Type Description
ISession

ResetSequenceNumbersViaLogonExchange()

Sends an intra-connection Logon (MsgType=A) message with the ResetSeqNumFlag (tag=141) flag set.

Declaration
public ISession ResetSequenceNumbersViaLogonExchange()
Returns
Type Description
ISession

Send(FlatMessage)

Declaration
public ISession Send(FlatMessage message)
Parameters
Type Name Description
FlatMessage message
Returns
Type Description
ISession

Send(IMessage)

Sends the given IMessage to the counterparty.

As soon as a session is created, it is possible to start sending messages via the session. If the session is not established, the messages are stored in the session storage and will be sent in reply to the Resend Request message when the connection is established and the sequence numbers mismatch is detected.

Warning: it is critical to avoid the message object modification until the method returns control.

Declaration
public ISession Send(IMessage message)
Parameters
Type Name Description
IMessage message

Message to send

Returns
Type Description
ISession

Send(Message)

Declaration
public ISession Send(Message message)
Parameters
Type Name Description
Message message
Returns
Type Description
ISession

Send(SerializedMessage)

Sends the given SerializedMessage to the counterparty.

As soon as a session is created, it is possible to start sending messages via the session. If the session is not established, the messages are stored in the session storage and will be sent in reply to the Resend Request message when the connection is established and the sequence numbers mismatch is detected.

Warning: it is critical to avoid the message object modification until the method returns control.

Declaration
public ISession Send(SerializedMessage message)
Parameters
Type Name Description
SerializedMessage message

Message to send

Returns
Type Description
ISession

Send(IEnumerable<IMessage>)

Sends messages in a batch to the counterparty.

As soon as a session is created, it is possible to start sending messages via the session. If the session is not established, the messages are stored in the session storage and will be sent in reply to the Resend Request message when the connection is established and the sequence numbers mismatch is detected.

Warning: it is critical to avoid the message object modification until the method returns control.

Declaration
public ISession Send(IEnumerable<IMessage> messages)
Parameters
Type Name Description
IEnumerable<IMessage> messages

Messages to send

Returns
Type Description
ISession

Send(IEnumerable<SerializedMessage>)

Sends messages in a batch to the counterparty.

As soon as a session is created, it is possible to start sending messages via the session. If the session is not established, the messages are stored in the session storage and will be sent in reply to the Resend Request message when the connection is established and the sequence numbers mismatch is detected.

Warning: it is critical to avoid the message object modification until the method returns control.

Declaration
public ISession Send(IEnumerable<SerializedMessage> messages)
Parameters
Type Name Description
IEnumerable<SerializedMessage> messages

Messages to send

Returns
Type Description
ISession

SendReject(int, string)

Sends the Reject (MsgType 3) message.

Declaration
public ISession SendReject(int refSeqNumber, string text)
Parameters
Type Name Description
int refSeqNumber

The sequence number of the rejected message.

string text

The reject reason text.

Returns
Type Description
ISession

SendResendRequest(int)

Sends the Resend Request (MsgType 2) message.

Normally, the "Resend Request" message is sent automatically. This method allows to simulate a sequence gap by sending this message manually in some venue-specific cases.

Note: This method should not be used in the normal scenarios.

Declaration
public ISession SendResendRequest(int beginSeqNumber)
Parameters
Type Name Description
int beginSeqNumber

The sequence number of the first requested message in the range.

Returns
Type Description
ISession

SendTestRequest(string, TimeSpan)

Sends the Test Request (1) message. The method blocks until the heartbeat message is received from the counterparty or timeout ended.

Declaration
public ISession SendTestRequest(string testReqId, TimeSpan timeout = default)
Parameters
Type Name Description
string testReqId

The identifier included in Test Request (MsgType 1) message to be returned in resulting Heartbeat (MsgType 0) message from the counterparty

TimeSpan timeout

Maximum interval to wait until the reply is received from the counterparty, 0 if no waiting is required

Returns
Type Description
ISession

Throttle()

Performs throttling of a session that must be called before each send function call. If the count of messages per time unit exceeds the throttling limit, the function will be blocked until the given time interval is passed.

Declaration
public ISession Throttle()
Returns
Type Description
ISession

ThrottlingLimit(int, TimeSpan)

Sets throttling limit parameters.

Declaration
public ISession ThrottlingLimit(int messagesCount, TimeSpan interval)
Parameters
Type Name Description
int messagesCount

The message limit per a time unit.

TimeSpan interval

The time interval to limit messages.

Returns
Type Description
ISession

ToString()

Returns a string that represents the session.

Declaration
public override string ToString()
Returns
Type Description
string
Overrides
object.ToString()

TryThrottle(bool)

Checks the throttling of a session that must be called before each send function call. If the count of messages per time unit exceeds the throttling limit, the function returns the delay until the sending becomes possible. Otherwise, it returns TimeSpan.Zero.

Declaration
public TimeSpan TryThrottle(bool resetWhenDelay = false)
Parameters
Type Name Description
bool resetWhenDelay

The flag to indicate if the amount of messages per throttling interval should be reset when a delay is returned.

Returns
Type Description
TimeSpan

WarmUp(IMessage)

Warms up the sending path.

Declaration
public ISession WarmUp(IMessage message)
Parameters
Type Name Description
IMessage message

message to be used for warm up

Returns
Type Description
ISession
Exceptions
Type Condition
NullReferenceException

if message is null

EngineException

if error occurs

ObjectDisposedException

If Session object is disposed

WarmUp(SerializedMessage)

Warms up the sending path.

Declaration
public ISession WarmUp(SerializedMessage message)
Parameters
Type Name Description
SerializedMessage message

message to be used for warm up

Returns
Type Description
ISession
Exceptions
Type Condition
NullReferenceException

if message is null

EngineException

if error occurs

ObjectDisposedException

If Session object is disposed

Events

BytesReceived

Data is received from the network.

Declaration
public event BytesReceivedEventHandler BytesReceived
Event Type
Type Description
BytesReceivedEventHandler

Error

Error condition is detected.

Declaration
public event EventHandler<SessionErrorEventArgs> Error
Event Type
Type Description
EventHandler<SessionErrorEventArgs>

InboundApplicationMessage

Application-level message is received from the counterparty.

Declaration
public event EventHandler<InboundMessageEventArgs> InboundApplicationMessage
Event Type
Type Description
EventHandler<InboundMessageEventArgs>

InboundSessionMessage

Session-level message is received from the counterparty.

Declaration
public event EventHandler<InboundMessageEventArgs> InboundSessionMessage
Event Type
Type Description
EventHandler<InboundMessageEventArgs>

MessageResending

Sent application-level message is about to be resent to the counterparty.

Declaration
public event EventHandler<MessageResendingEventArgs> MessageResending
Event Type
Type Description
EventHandler<MessageResendingEventArgs>

MessageSending

Message is about to be sent to the counterparty.

Declaration
public event EventHandler<MessageSendingEventArgs> MessageSending
Event Type
Type Description
EventHandler<MessageSendingEventArgs>

OutboundApplicationMessage

Application-level message will be sent to the counterparty.

Declaration
public event EventHandler<MessageEventArgs> OutboundApplicationMessage
Event Type
Type Description
EventHandler<MessageEventArgs>

OutboundSessionMessage

Session-level message will be sent to the counterparty.

Declaration
public event EventHandler<MessageEventArgs> OutboundSessionMessage
Event Type
Type Description
EventHandler<MessageEventArgs>

ResendingFinished

Resending process is completed.

Declaration
public event EventHandler<ResendingStartedFinishedEventArgs> ResendingFinished
Event Type
Type Description
EventHandler<ResendingStartedFinishedEventArgs>

ResendingStarted

ResendRequest (MsgType=2) message is received and the session is about to start resending messages.

Declaration
public event EventHandler<ResendingStartedFinishedEventArgs> ResendingStarted
Event Type
Type Description
EventHandler<ResendingStartedFinishedEventArgs>

StateChanged

Session state is changed.

Declaration
public event EventHandler<SessionStateChangeEventArgs> StateChanged
Event Type
Type Description
EventHandler<SessionStateChangeEventArgs>

Warning

Warning condition is detected.

Declaration
public event EventHandler<SessionWarningEventArgs> Warning
Event Type
Type Description
EventHandler<SessionWarningEventArgs>

Implements

ISession
IDisposable
In this article
Back to top Copyright © Onix Solutions.
Generated by DocFX