forwardToFixString Method    Table of ContentSession Constructor forward
Session Class
FIX Session - a bi-directional stream of ordered messages between two parties within a continuous sequence number series.
Inheritance Hierarchy
System.Object
  FIXForge.NET.FIX.Session

Namespace:  FIXForge.NET.FIX
Assembly:  FIXForge.NET.FIX.Engine-net-4.8_x64 (in FIXForge.NET.FIX.Engine-net-4.8_x64.dll) Version: 4.12.0.0
Syntax
C#
public class Session : IDisposable, ISession

The Session type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyConsiderRejectOnResendRequestAsGapFill
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.
Public propertyCounterpartyHost
Gets the counterparty host name or IP address. Note: The property performs a DNS request for the first time. Therefore, it can block the thread execution for a long time until the DNS request is completed.
Public propertyCounterpartyIpAddress
Gets the counterparty IP address.
Public propertyCounterpartyPort
Gets the counterparty port number.
Public propertyCreationTime
Time when the session instance was created or last local reset for sequence numbers was performed.
Public propertyCustomKey
Gets session's custom key.
Public propertyDialect
FIX dialect used by the session.
Public propertyEncryption
Method of encryption
Public propertyHeartBtInt
Gets the Heartbeat interval (seconds, HeartBtInt, tag=108 field value).
Public propertyIgnoreLessThanExpectedSequenceNumber
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.
Public propertyInboundMessageLogFilter
Incoming message types to be filtered out from the logs.
Public propertyIncomingMessageGapQueueMaximumSize
If RequestOnlyMissedMessages property is true and the sequence number of an incoming FIX message greater than expected then the resend functionality is run and this incoming message is stored in the incoming message gap queue for further processing. This property allows setting the maximum size of that queue. By default, the value equal to 1000.
Public propertyInSeqNum
Gets or sets the expected sequence number of the next incoming message.
Public propertyIsDisposed
Returns true if the FIX session object is disposed, false otherwise.
Public propertyKeepSequenceNumbersBetweenFixConnections
Option to keep sequence numbers after the exchange of Logout (MsgType=5) messages. By default, the value is true
Public propertyListenPort
Port to listen on for incoming connections in acceptor mode.
Public propertyLocalInterface
Network interface used by the session.
Public propertyLocalPort
Outgoing local port used by initiator session. By default, a system (random) port will be used.
Public propertyLocalPortRange
Local port range for outgoing connections.
Public propertyLogBeforeSending
Option to switch on/off logging of outbound messages before/after sending.
Public propertyLogDirectory
Inbound and outbound messages, session's state data are stored in this directory. By default, the value of the LogDirectory is used.
Public propertyLogInboundMessages
Option to log incoming messages. By default, the value is true.
Public propertyLogOutboundMessages
Option to log outgoing messages. By default, the value is true.
Public propertyMessageGrouping
Specifies the number of messages that should be written to the outgoing TCP buffer together. By default, the value of the MessageGrouping is used.
Public propertyMessageMode
The session message mode.
Public propertyOutboundMessageLogFilter
Outgoing message types to be filtered out from the logs.
Public propertyOutboundQueueBytes
Number of bytes in the outbound queue.
Public propertyOutSeqNum
Gets or sets the sequence number of the next outgoing message.
Public propertyProxy
HTTP proxy settings.
Public propertyReceiveSpinningTimeoutUsec
Option to specify the non-blocking receive spinning timeout (in microseconds) before the receiving thread enters into the blocking wait mode. The value should not be greater than 1 sec (minimal Heartbeat interval). By default, the option value is zero, therefore the value of the ReceiveSpinningTimeout is used.
Public propertyReceivingThreadAffinity
Gets or sets the CPU affinity of the receiving thread.
Public propertyReceivingThreadPriority
Gets or sets the priority of the session receiving thread. The default value is set by OS.
Public propertyReconnectAttempts
Option to specify the number of attempts to restore the FIX connection. By default, the value of the ReconnectAttempts is used.
Public propertyReconnectInterval
Option to specify the time interval between the attempts to restore the FIX connection (in seconds). By default, the value of the ReconnectInterval is used.
Public propertyReportNewMessagesWhileWaitingForMissedMessages
When the message gap is detected the "Resend Request" FIX Message is sent and Session state is changed to "AwaitReplyOnResendRequest". 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.
Public propertyRequestOnlyMissedMessages
By default, the "Resend Request" message requests all messages begin from the first missed one. This property allows to change this behavior and request only missed messages.
Public propertyResendingQueueSize
Number of sent messages that are available for resending on counterpart's Resend Request <2> message. By default, the option value equal to -1, therefore the value of the ResendingQueueSize is used.
Public propertyResendRequestMaximumRange
Maximum number of messages to be requested in one Resend Request (MsgType=2) message. By default, the value of the ResendRequestMaximumRange is used.
Public propertyResendTimeout
Timeout during which counterparty should send a reply to the ResendRequest (MsgType=2) message. If a counterparty does not reply or reply incorrectly during this timeout, then the WarningEvent is called. By default, the resend request timeout equal to zero, which means an infinite timeout. Note: The resend timeout is checked when an incoming message is received or when the receive timeout is elapsed. Therefore, the actual timeout can be greater than the specified one or can be rounded to the value equal to the heartbeat interval + reasonable transmission time.
Public propertyResetLocalSequenceNumbersOnLogon
Option to automatically reset the local sequence numbers to 1 during every logon.
Public propertyReuseEventArguments
Option which enables reusing of event arguments by Session (By default,it is disabled). If turns on, client's code must copy event arguments for using outside of callbacks.
Public propertyReuseIncomingMessage
Option which enables reusing of an incoming message by Session (By default,it is disabled). If turns on, client's code should not dispose incoming messages and must copy message for using outside of inbound callbacks.
Public propertyReuseOutgoingMessage
Option which enables reusing of an outgoing message by Session (By default,it is disabled). If turns on, client's code should not dispose outgoing messages and must copy message for using outside of outbound callbacks.
Public propertyRole
Gets the session role.
Public propertyScrambleLogonFields
Option to set scrambled fields in the Logon (MsgType=A) message, in the session storage, for security reasons.
Public propertySenderCompID
Gets the assigned value used to identify firm sending message (SenderCompID (49) field value in outgoing messages).
Public propertySenderLocationID
Value of SenderLocationID, tag=142 field for all outgoing messages.
Public propertySenderSubID
Value of SenderSubID, tag=50 field for all outgoing messages.
Public propertySendingThreadAffinity
Gets or sets the CPU affinity of the sending thread.
Public propertySendingThreadPriority
Gets or sets the priority of the session sending thread. The default value is set by OS.
Public propertySendingTimeFormat
Sets the time format of SendingTime of every sent message. By default, the YYYYMMDDHHMMSSMsec format is used.
Public propertySendLogoutOnException
Option to send the Logout message before dropping the telecommunication link in case of Exception during the processing of incoming FIX message. By default, the value of the SendLogoutOnException is used.
Public propertySendQueueMaxSize
The option to set the send queue maximum size in bytes. By default, the value of the SendQueueMaxSize is used (0.5 Gb).
Public propertySendResendRequestOnEachMessageGap
By default, the "Resend Request" message is sent only once - when the first gap is detected. This property allows sending the "Resend Request" message on each detected message sequence number gap.
Public propertySendSpinningTimeoutUsec
Option to specify the send spinning timeout (in microseconds) of the Send(Message) 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). The value should not be greater than 1 sec (minimal Heartbeat interval). By default, the option value is zero, therefore the value of the SendSpinningTimeout is used.
Public propertySpecifyLastMsgSeqNumProcessed
Option to specify the LastMsgSeqNumProcessed, tag=369 field on every message sent. Useful for detecting a backlog with a counterparty. By default, the value of the SpecifyLastMsgSeqNumProcessed is used.
Public propertySsl
SSL encryption settings.
Public propertyState
Session's state.
Public propertyStorageID
Session's ID in the Session Storage.
Public propertyStorageType
Session's storage type.
Public propertySupportNextExpectedMsgSeqNum
Option to support NextExpectedMsgSeqNum field (tag 789) in Logon (MsgType=A) messages. By default, the option value is false.
Public propertyTargetCompID
Assigned value used to identify receiving firm (TargetCompID, tag=56 field value in outgoing messages).
Public propertyTargetLocationID
Value of TargetLocationID, tag=143 field for all outgoing messages.
Public propertyTargetSubID
Value of TargetSubID, tag=57 field for all outgoing messages.
Public propertyTcpNoDelayOption
Option to improve latency at the expense of message throughput. By default, the value of the TcpNoDelayOption is used.
Public propertyThreadNameSuffix
Thread name suffix for receiving ("R:threadNameSuffix") and sending ("S:threadNameSuffix") threads. If threadNameSuffix is not specified, the name of receiving and sending threads sets by default ("R:senderCompId-targetCompId")("S:senderCompId-targetCompId").
Public propertyStatic memberUnknownSessionCreationTime
Constant which denotes that the session creation time is undefined.

This value should be returned by SessionCreationTime implementation unless the Engine did not updated the property.

Public propertyUpdateSendingTimeField
Option to specify updating of SendingTime of every sent message. By default, the option value is true.
Public propertyValidateChecksum
Option to turn on/off incoming message checksum validation. By default, the option value is false.
Public propertyValidateDuplicatedField
Option to turn on/off incoming message field duplicate validation. By default, the option value equal to ValidateDuplicatedField.
Public propertyValidateEmptyFieldValues
Option to validate empty message field values. By default, the option value equal to the ValidateEmptyFieldValues.
Public propertyValidateFieldValues
Option to validate field values of FIX messages in accordance with the FIX protocol or its FIX Dialect. By default, the option value equal to the ValidateFieldValues.
Public propertyValidateRepeatingGroupEntryCount
Option to validate that the declared number of repeating group instances is equal to the actual one. By default, the option value equal to ValidateRepeatingGroupEntryCount.
Public propertyValidateRepeatingGroupLeadingTag
Option to validate that repeating group starts from required by dialect leading tag. By default, the option value equal to ValidateRepeatingGroupLeadingTag.
Public propertyValidateRequiredFields
Option to validate that all required fields are set. By default, the option value equal to the ValidateRequiredFields.
Public propertyValidateSequenceNumbers
Option to turn on/off incoming message sequence numbers validation. By default, the option value is true.
Public propertyValidateUnknownFields
Option to validate that there are no unknown message fields. By default, the option value equal to the ValidateUnknownFields.
Public propertyValidateUnknownMessages
Option to validate that there are no unknown messages received. By default, the option value equal to the ValidateUnknownMessages.
Public propertyVersion
Gets the session FIX version.
Top
Methods
  NameDescription
Public methodBreakConnection
Breaks the FIX Connection non-gracefully (without the exchange of Logout (MsgType=5) messages).
Public methodClearOutboundQueue
Removes all messages from the outbound queue.
Public methodDispose()
Terminates the FIX Session, explicitly releases resource and removes the object from Garbage Collector.
Protected methodDispose(Boolean)
Releases the unmanaged resources used by the Session and optionally releases the managed resources
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Perform cleanup operations on unmanaged resources held by the current Session object before the object is destroyed.
(Overrides Object.Finalize().)
Public methodFindSentFlatMessage
Finds the sent FIX message by the given message sequence number. Returns null if the message is not found.
Public methodFindSentMessage
Finds the sent FIX message by the given message sequence number. Returns null if the message is not found.
Public methodFlushSessionStorage
Flushes all internal buffers of the underlying storage.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodLogonAsAcceptor
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.

Public methodLogonAsInitiator(String, Int32)
Establishes FIX Connection as Initiator using the default heartbeat value.

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

The heartbeat interval will be 30 seconds.

Public methodLogonAsInitiator(String, Int32, Boolean)
Establishes FIX Connection as Initiator using the default heartbeat value, optionally sets ResetSeqNumFlag (tag=141) field in the initial Logon (MsgType=A) message.

Initiator establishes the telecommunications link and initiates the session via transmission of the initial Logon (MsgType=A) message.

The heartbeat interval will be 30 seconds.

Public methodLogonAsInitiator(String, Int32, Int32)
Establishes FIX Connection as Initiator.

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

Public methodLogonAsInitiator(String, Int32, Int32, Message)
Establishes FIX Connection as Initiator using the custom Logon message.

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

Public methodLogonAsInitiator(String, Int32, Int32, Boolean)
Establishes FIX Connection as Initiator.

Initiator establishes the telecommunications link and initiates the session via transmission of the initial Logon (MsgType=A) message.

Public methodLogonAsInitiator(String, Int32, Int32, Message, Boolean)
Establishes FIX Connection as Initiator using a custom Logon message with an optional ResetSeqNumFlag (tag=141) field.

Initiator establishes the telecommunications link and initiates the session via transmission of the initial Logon (MsgType=A) message.

Public methodLogonAsInitiatorAsync
Establishes FIX Connection asynchronously as Initiator using a custom Logon message with an optional ResetSeqNumFlag (tag=141) field.

Initiator establishes the telecommunications link and initiates the session via transmission of the initial Logon (MsgType=A) message. The method returns immediately without waiting the acknowledgment Logon message.

Public methodLogout()
Terminates the FIX Connection.

The initial Logout message is sent to the counterparty and the method blocks until the acknowledgement Logout message is received or the Heartbeat interval is elapsed.

Public methodLogout(String)
Terminates the FIX Connection.

The initial Logout (MsgType=5) message is sent to the counterparty and the method blocks until the acknowledgement Logout message is received.

Public methodLogout(Message)
Terminates the FIX Connection.

The initial Logout message is sent to the counterparty and the method blocks until the acknowledgement Logout message is received.

Public methodLogoutAsync(String)
Terminates the FIX Connection.

The initial Logout (MsgType=5) message is sent to the counterparty and the method returns immediately without waiting the acknowledgment Logout message.

Public methodLogoutAsync(Message)
Terminates the FIX Connection.

The initial Logout message is sent to the counterparty and the method returns immediately without waiting the acknowledgment Logout message.

Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnErrorEvent
Called when Error condition is detected.
Protected methodOnInboundApplicationMsgEvent
Called when the Application-level message is received.
Protected methodOnInboundSessionMsgEvent
Called when the Session-level message is received.
Protected methodOnMessageResending
Called when the sent application-level message is about to be re-sent to the counterpart in reply to the ResendRequest (MsgType=2) message.
Protected methodOnOutboundApplicationMsgEvent
Called when the Application-level message is sent.
Protected methodOnOutboundSessionMsgEvent
Called when the Session-level message is sent.
Protected methodOnResendingFinished
Called when the resending process is completed.
Protected methodOnResendingStarted
Called when the ResendRequest (MsgType=2) message is received and the session is about to start resending messages.
Protected methodOnStateChangeEvent
Called when the session changes its state.
Protected methodOnWarningEvent
Called when a warning condition is detected.
Public methodPreFill(FlatMessage)
Pre-fills the following fields for sending as is: Session-level fields that are constant during the session's lifetime - SenderCompId, TargetCompId, SenderLocationId, TargetLocationID, SenderSubID, TargetSubID. MsgSeqNum field in accordance with the session outgoing sequence number. SendingTime field. BodyLength and CheckSum fields.
Public methodPreFill(FlatMessageBatch)
Pre-fills the following fields in the batch for sending as is: Session-level fields that are constant during the session's lifetime - SenderCompId, TargetCompId, SenderLocationId, TargetLocationID, SenderSubID, TargetSubID. MsgSeqNum field in accordance with the session outgoing sequence number. SendingTime field. BodyLength and CheckSum fields.
Public methodPreFill(Message)
Pre-fills session-level fields that are constant during the session's lifetime - SenderCompId, TargetCompId, SenderLocationId, TargetLocationID, SenderSubID, TargetSubID.
Public methodResetLocalSequenceNumbers
Resets the local sequence numbers to 1 and backups the current log files (if file-based session storage is used). This method can be called only when the session is disconnected.
Public methodResetSequenceNumbersViaLogonExchange
Sends an intra-connection Logon (MsgType=A) message with the ResetSeqNumFlag (tag=141) flag set.
Public methodScheduleShrinkToFit
Schedule the memory usage optimization. The session will perform the actual memory usage optimization after receiving and processing the next incoming message.
Public methodSend(FlatMessage)
Sends the serialized message to the counterparty.

This method is asynchronous. 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 replay to the resend request when the connection is established with the counterparty and the sequence numbers mismatch is detected.

Public methodSend(FlatMessageBatch)
Sends messages in a batch to the counterparty.

This method is asynchronous. 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 replay to the resend request when the connection is established with the counterparty and the sequence numbers mismatch is detected.

Public methodSend(Message)
Sends the message to the counterparty.

This method is asynchronous. 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 replay to the resend request when the connection is established with the counterparty and the sequence numbers mismatch is detected.

Public methodSend(MessageBatch)
Sends messages in a batch to the counterparty.

This method is asynchronous. 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 replay to the resend request when the connection is established with the counterparty and the sequence numbers mismatch is detected.

Public methodSend(FlatMessageBatch, Int32)
Sends messages in a batch to the counterparty.

This method is asynchronous. 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 replay to the resend request when the connection is established with the counterparty and the sequence numbers mismatch is detected.

Public methodSend(MessageBatch, Int32)
Sends messages in a batch to the counterparty.

This method is asynchronous. 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 replay to the resend request when the connection is established with the counterparty and the sequence numbers mismatch is detected.

Public methodSendAsIs(FlatMessage)
Sends a message to the counterparty without any fields updating.

This method is asynchronous. 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 replay to the resend request when the connection is established with the counterparty and the sequence numbers mismatch is detected.

Public methodSendAsIs(FlatMessageBatch)
Sends messages in a batch to the counterparty without any fields updating.

This method is asynchronous. 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 replay to the resend request when the connection is established with the counterparty and the sequence numbers mismatch is detected.

Public methodSendAsIs(FlatMessageBatch, Int32)
Sends messages in a batch to the counterparty without any fields updating.

This method is asynchronous. 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 replay to the resend request when the connection is established with the counterparty and the sequence numbers mismatch is detected.

Public methodSendReject
Sends the Reject (MsgType=3) message.
Public methodSendResendRequest
Normally, Resend Request (MsgType=2) message is sent automatically. This method allows simulating a sequence gap by sending this message manually. This can be needed in some venue specific cases. This method should not be used in the normal work.
Public methodSendTestRequest(String)
Sends the Test Request (MsgType=1) message.
Public methodSendTestRequest(String, TimeSpan)
Sends the Test Request (MsgType=1) message and waits until the heartbeat message is received from the counterparty or timeout ended
Public methodThrottle
Performs throttling of a session that must be called before each of a send function call. If the count of messages per a time unit exceeds a throttling limit, the function will be blocked until the given time interval is passed.
Public methodThrottlingLimit
Sets throttling limit parameters.
Public methodToString
Returns a string that represents the current session.
(Overrides Object.ToString().)
Public methodWarmUp
Warms up the sending path.
Top
Events
  NameDescription
Public eventBytesReceived
Raised when bytes received by the session.
Public eventErrorEvent
Error condition is detected.
Public eventInboundApplicationMsgEvent
Application-level message is received from the counterparty.
Public eventInboundSessionMsgEvent
Session-level message is received.
Public eventMessageResending
Sent application-level message is about to be resent to the counterparty.
Public eventMessageSending
Message is about to be sent to the counterparty.
Public eventOutboundApplicationMsgEvent
Application-level message will be sent to the counterparty.
Public eventOutboundSessionMsgEvent
Session-level message will be sent to the counterparty.
Public eventResendingFinished
Resending process is completed.
Public eventResendingStarted
ResendRequest (MsgType=2) message is received and the session is about to start resending messages.
Public eventStateChangeEvent
Session state is changed.
Public eventWarningEvent
Warning condition is detected.
Top
Fields
  NameDescription
Public fieldStatic memberResendRequestMaximumRangeNoLimit
Represents unlimited number of messages to be requested in one Resend Request (MsgType=2) message.
Top
See Also