image/svg+xml
  • OnixS .NET FIX Engine
  • Programming Guide
  • Api Documentation
  • Version 1.16.1
    • Programming Guide
    • FIX Session
    • Establishing FIX Connection
Show / Hide Table of Contents
  • Introduction
  • System Requirements
  • Project Dependency Management
  • Getting Started
  • Error Reporting
  • Licensing
  • Engine Initialization and Shutdown
  • Selecting FIX Version
  • FIX Message
    • Manipulating Message Fields
  • FIX Session
    • Establishing FIX Connection
    • Exchanging Messages
    • Message Sequence Numbers
  • Configuring the Engine
    • Loading Engine Settings From Configuration Files
    • Multiple Listen Ports
  • Logging Services
    • Selecting Session Storage
    • Customizing Message Logging
  • Threading Model
  • Thread Safety
  • Repeating Groups
  • Sessions
    • Session States
    • Session Events
    • Accepting FIX Session Without a Prior Creation of Session Object
    • Custom Logon Message
    • Logon Authentication
    • Establishing FIX Connection via Proxy
    • Asynchronous Logon/Logout
    • Resetting Message Sequence Numbers
    • Resetting Message Sequence Numbers via ResetSeqNumFlag Field
    • Resending Messages
    • Memory-based Session Storage
    • File-based Session Storage
    • Async File-based Session Storage
    • Pluggable Session Storage
    • Scheduling Session for Automatic Connection
      • Session Schedule
      • Session Connection Settings
      • XML-based Schedules and Connection Settings
    • Failover
    • Message Sending Latency
    • Message Receiving Latency
    • Message Throttling
  • Messaging
    • Manipulating Real Numbers
    • Message Validation
    • Serialized FIX Messages
    • Typed FIX Messages
    • Flat Messages
      • Flat Group Reader
    • Using LINQ
  • FIX Dictionary
    • XML-based Dictionary Description
    • Session-level Dictionary
    • Dictionary Exploration
    • Using QuickFIX Data Dictionary
  • Engine Events
  • TLS/SSL Encryption
    • Using TLS/SSL Encryption
    • Supported Certificates
    • Session-level TLS/SSL Settings
    • Verification of Client SSL Certificates
    • Custom verification of SSL Certificates
    • TLS/SSL Troubleshooting
  • FAST Coding
    • Encoding And Decoding Data Using FAST
    • FAST Template
    • Generating FIX Dictionaries For FAST Coding
    • FAST Exceptions
  • FIXML Converter
  • Reducing Garbage Collection Overhead
  • Best Practices
    • Low Latency Best Practices
    • High Throughput Best Practices
  • Migration Guide
  • Frequently Asked Questions
  • Glossary
  • External Resources
  • Samples
  • Support

Establishing FIX Connection

Session Role

A Session can participate in FIX connection in one of two roles: as an Acceptor or as an Initiator.

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

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

To determine the role of the session use the Role property.

Establishing Connection

To establish a FIX connection as an Acceptor use the LogonAsAcceptor() method.

To establish a FIX connection as an Initiator use the LogonAsInitiator(string, int, int, bool, IMessage, bool) method.

For example:

const string SenderCompId = "SenderCompID";
const string SargetCompId = "TargetCompID";
const ProtocolVersion Version = ProtocolVersion.Fix44;
const string CounterpartyHost = "localhost";

// In this sample the target port is equal to acceptor's port to create a loop-back FIX session.
int CounterpartyPort = Engine.Instance.Settings.ListenPorts[0];

using Session acceptor = new Session(SenderCompId, SargetCompId, Version);
acceptor.LogonAsAcceptor();

using (Session initiator = new Session(SargetCompId, SenderCompId, Version))
{
    // Sends the Logon message and waits for the acknowledgment Logon.
    initiator.LogonAsInitiator(CounterpartyHost, CounterpartyPort);

    // Message exchange and processing logic

    // Sends the Logout message and waits for the confirming Logout.
    initiator.Logout();
}

acceptor.Logout();

Closing Connection

To disconnect the session use the Logout(bool) method. This member implements a graceful closing of the FIX connection as defined by the FIX Protocol Standard.

Note

LogonAsInitiator(string, int, int, bool, IMessage, bool) and Logout(bool) methods are blocked until the Logon/Logout response message is received. These methods have a timeout during which the response should be received. This timeout is equal to the Heartbeat interval (by default 30 sec) + ReasonableTransmissionTime value (by default 20%) as a percentage from the heartbeat interval. If the acknowledgment Logon/Logout message is not received during the timeout, then the Logout message will be sent and the FIX connection will be closed.

Reconnection Service

When a FIX session is in the active state, and there are some network issues the FIX Engine will try to restore the FIX connection per ReconnectAttempts and ReconnectInterval settings.

Note

Reconnection service works for already established connections. In other cases, you need to use the Sessions Scheduler component or manually handle LinkErrorException or LogonReplyTimeoutException exceptions of LogonAsInitiator(string, int, int, bool, IMessage, bool) method and try to connect again.

Connection and Session Lifetime

A single FIX session can exist across multiple sequential (not concurrent) physical connections.

Parties can connect and disconnect multiple times while maintaining a single FIX session.

Once the Logout(bool) method is called, the FIX Connection is terminated; however, the FIX session life continues. It is possible to continue the same session later using either LogonAsAcceptor() or LogonAsInitiator(string, int, int, bool, IMessage, bool) methods again.

In other words, a FIX Session consists of one or more FIX connections.

See Also

  • Session State
  • Message Sequence Numbers
  • Custom Logon Message
In this article
  • Session Role
  • Establishing Connection
  • Closing Connection
  • Reconnection Service
  • Connection and Session Lifetime
  • See Also
Back to top Copyright © Onix Solutions.
Generated by DocFX