Home » Products » FF.FIX Engine » FF.FIX Engine Knowledgebase » FIX Acceptor

FIX Acceptor

The role of a FIX Acceptor is to:

  • Listen to FIX session initiating (Buy-side) counterparties at a designated port.
  • Validate and authenticate a FIX session initiating Logon message from its counterparty.
  • Declare a FIX session as 'accepted' by sending a counter-Logon message after successful validation and authentication of the session initiating Logon message.
  • Reject and terminate the connection in case of failure in validation and authentication of session initiating Logon message.
  • Listen to inbound messages in established FIX sessions.
  • Close socket connection if the counterparty becomes 'dead'.

FF.FIX Engine's API library makes it easy for you to develop an application that can function like a FIX Acceptor and accept FIX connections from several FIX compliant Buy-side counterparties and hold several FIX sessions simultaneously.

The following diagram presents an architectural view of a FF.FIX Engine based Acceptor application:

A FF.FIX Engine based FIX Acceptor application has the following components:

Component details Role in the Initiator application
  • Component name: Callback handler
  • Class: FixAcceptorHandler
  • Namespace: FF.Fix.Acceptor
Provides a callback interface to listen to important events and exchanged messages during a FIX session.

You can process the received events as per your requirements using different methods of the FixAcceptorHandler class. For details, see FIX Acceptor Handler.

  • Component name: FIX session configuration
  • Class: FixConfig
  • Namespace: FF
The FixConfig class represents an object model for the declarative FIX configuration file in XML format. It contains the parameters you defined for controlling a FIX session.
  • Component name: Persistence layer
  • Class: FixDBConfig
  • Namespace: FF
The persistence layer for a FIX session uses a RDBMS. The FixDBConfig class provides details about it.
  • Component name: Configurations for target counterparties
  • Class: AcceptorTargetConfigList
  • Namespace: FF.Fix.Acceptor
The AcceptorTargetConfig class provides FIX configurations of all Buy-side counterparties.

Only registered counterparties can connect to the FIX Acceptor application. Each instance of the AcceptorTargetConfig class signifies a separate registered counterparty.

  • Component name: List of target counterparties
  • Class: FixAlertManager
  • Namespace: FF.Fix
The AcceptorTargetConfigList class maintains a list of all AcceptorTargetConfig objects (list of all supported counterparties).

::FAQ::

  1. How do I setup my FIX Acceptor to accept FIX connections?
  2. What is the significance of the FixAcceptorHandler callback interface?
  3. How does my FIX Acceptor application identify the counterparties that it can accept?
  4. Is it possible to make my Acceptor application accept a connection request from a new counterparty, unknown to it during the Init() call?
  5. If the Init() call on an Acceptor instance does not provide the server-IP address, which IP address does it use to listen to its counterparties?
  6. Does a Start() call of the Acceptor also start all the sessions maintained by the Acceptor?
  7. How do I come to know about the acceptance of a new Initiator connection and creation of a new FixSession by the Acceptor?
  8. Can I stop the configured counterparties from establishing connections with my Acceptor application?
  9. How do I identify all FixSession instances and their current session states?
  10. How do I set different messaging rules for different counterparties (Initiator sessions)?
  11. How do I logout a particular counterparty without affecting the transactions it made?
  12. Does the Acceptor class provide help in order matching?
  13. How does my Acceptor application validate the credentials of a session initiating counterparty?
  14. How can my Acceptor application know about the change of state of a FixSession maintained by it?
  15. How do I use SSL?
  1. How do I setup my FIX Acceptor application to accept FIX connections?

Initialize the list of Initiators.
Initialize the database configuration.
Implement FIX Acceptor Handler.
Instantiate and Initialize the Acceptor.

Step 1: Initialize the list of Initiators (Buy-sides)
Initialize the list of Initiators that your FIX Acceptor shall allow by adding a separate AcceptorTargetConfig object for each allowed Initiator counterparty (Buy-side).

For example:

FixConfig fixConfig = new FixConfig("Initiator.Config");
AcceptorTargetConfig sampleInitiator = new AcceptorTargetConfig(FixVersion.BEGINSTRING_Fix42, "SampleInitiator", fixConfig);
AcceptorTargetConfigList acceptorTargetConfigList = new AcceptorTargetConfigList();
acceptorTargetConfigList.Add(sampleInitiator);

Step 2: Initialize the database configuration
Initialize the database configuration for your FIX Acceptor application as shown in the sample code below:

string dbServer ="(local)";
string dbName = "FFFix";
string userName = "SampleUser";
string dbConnString = string.Format("Data Source={0};Initial Catalog={1};IntegratedSecurity=SSPI;Pooling=true;Min Pool Size=0;Max Pool Size=100;Connect Timeout=30", dbServer, dbName);
FixPersistConfig persistConfig = new FixDBConfig(FF.Fix.Core.eDBProvider.SqlServer, dbConnString);

Step 3: Implement the FIX Acceptor Handler
Implement the callback methods as required. For details, see FIX Acceptor Handler.

FixAcceptorHandler fixAcceptorHandler = new ApplicationCallbackHandler();

Step 4: Instantiate and initialize the Acceptor.

acceptor.Init(userName, "SampleAcceptor", acceptorTargetConfigList, persistConfig, fixAcceptorHandler, System.Net.IPAddress.Loopback.ToString(), 9999);

  1. What is the significance of the FixAcceptorHandler callback interface?

An Acceptor maintains multiple FixSession instances simultaneously on multiple threads. The FF.FIX Engine library does not provide the business logic as it pertains to your organization's specific requirements (back office part). Instead it provides callbacks on different events, which you can further customize as required.

For example, FF.FIX internally uses methods of the FixAcceptorHandler callback interface to notify the application about events in the ongoing sessions. You can develop your order processing functionality based on these callbacks and by overriding the base implementation in the callback methods.

See following code snippet for a typical Acceptor callback handler:

using System;
using System.Collections.Generic;
using System.Text;
using FF.Fix;
using FF.Fix.Acceptor;
using FF.Fix.Core.Message;
namespace AcceptorApplication

{
    internal sealed class AcceptorCallbackListner: FF.Fix.Acceptor.FixAcceptorHandler

    {
        public AcceptorCallbackListner(MainForm mainForm)
        {
        }

        public override void OnSessionCreation(FixSession fixSession)
        {
        }

        public override void OnConnectionBreak(FixSession fixSession, string failReason)
        {
        }

        public override void OnLogonMessage(FixSession fixSession, FixMessage message)
        {
            //Verify the Logon from Initiator and the send an Acknowledgment Logon.
            string userName = message.GetFieldAsString(FixFieldTag.Username_553);
            string password = message.GetFieldAsString(FixFieldTag.Password_554);

            //Validate user name and password as agreed between Acceptor and Initiator applications.
            if (Validate(userName, password))
            {
                //Valid Logon, Send Logon Acknowledgment
                FixMessage fixLogonMessage = fixSession.GetSessionFixMessage("A");
                fixLogonMessage.SetField(FixFieldTag.HeartBtInt_108, "30");
                fixLogonMessage.SetField(FixFieldTag.EncryptMethod_98, "0");
                fixSession.SendMessage(fixLogonMessage);
            }
            else
            {
                FixMessage logoutFixMessage = fixSession.GetLogoutMessage("Invalid Password. Logout Forced");
                fixSession.SendMessage(logoutFixMessage);
                return;
            }
        }

        public override void OnLogoutMessage(FixSession fixSession, FixMessage message)
        {
        }

        public override void OnRejectMessage(FixSession fixSession, FixMessage message, int rejectedMessageSeqNum)
        {
        }

        public override void OnApplicationMessage(FixSession fixSession, FixMessage message)
        {
            _mainForm.OnSessionApplicationMessageReceived(fixSession, message);
        }

        public override void InBoundQueueSizeThresholdValueReached(FixSession fixSession)
        {
        }

        public override void OnSessionTransmissionFail(FixSession fixSession, DateTime lastMessageRecvAt)
        {
        }
    }
}

  1. How does my FIX Acceptor application identify the counterparties that it can accept?

The AcceptorTargetConfigList parameter in the Init() call of an Acceptor contains a list of AcceptorTargetConfig instances. Each instance represents a separate allowed counterparty.

By comparing the information in the session initiating Logon message against the list of AcceptorTargetConfig objects, a FIX Acceptor application identifies the counterparties it can accept. The AcceptorTargetConfig class documentation in the FF.FIX Engine documentation provides details about the values you require to supply.

  1. Is it possible to make my Acceptor application accept a connection request from a new counterparty, unknown to it during the Init() call?

Yes, you can make such a provision in your Acceptor application using the following function:

public void AddNewAcceptorTargetConfig (AcceptorTargetConfig acceptorTargetConfig)

For details, see the AcceptorTargetConfig class documentation in the FF.FIX Engine documentation.

  1. If the Init() call on an Acceptor instance does not provide the server-IP address, which IP address does it use to listen to its counterparties?

If the server IP address is not supplied or an empty string is supplied during the Init() call of an Acceptor, it identifies the list of network interfaces existing on the Acceptor server and selects the first IP address from this list to listen to its counterparties.

  1. Does a Start() call of the Acceptor also start all the sessions maintained by the Acceptor?

The FixSession instances maintained by the Acceptor are started or initiated only after an explicit request from the connecting counterparty. As a first step, the connecting counterparty (session Initiator) establishes the socket connection with the Acceptor application. After establishing the socket connection, the Acceptor application waits for a Logon message (MsgType = A) from the Initiator for a period specified by the InitiatorLogonTimeOut key in the FIX configuration. (XML file). If the Initiator fails to send a Logon message within this period, the Acceptor application closes the socket connection for that session Initiator.

  1. How do I come to know about the acceptance of a new Initiator connection and creation of a new FixSession by the Acceptor?

For this purpose the Acceptor class exposes the following events and callbacks:

  • NewClientSocketConnectEvent: The Acceptor raises this event on accepting a new socket connection from the counterparty. The creation of a FixSession object is totally dependent on the validation and authentication of the Logon message from the Initiator counterparty. Hence, this event does not imply the creation of a FixSession instance for that counterparty.
  • NewFixSessionCreatedEvent: The Acceptor raises this event after successful authentication of the Logon message from the Initiator counterparty and creation of a FixSession instance for that counterparty.
  • OnSessionCreation(): The Acceptor invokes this callback method on the FixAcceptorHandler object before the validation of the Logon message received from the counterparty. The FixAcceptorHandler object is supplied as a parameter during the Init() call of the Acceptor. On the contrary, the NewFixSessionCreatedEvent event is raised only after the successful validation and authentication of the Logon message.
  1. Can I stop the configured counterparties from establishing connections with my Acceptor application?

Yes, you may require this type of action if the system is under high stress. Without affecting the ongoing sessions, it is possible prohibit your Acceptor application from accepting any new connections and from creating new FixSession instances by setting the AcceptNewConnection property in the Acceptor instance to false.

  1. How do I identify all FixSession instances and their current session states?

The Acceptor class creates a FixSessionInfo object for each AcceptorTargetConfig object supplied to it during the Init() call and also for the AcceptorTargetConfig objects added to it at any later stage. You can access the list of FixSessionInfo objects using the following function exposed by the Acceptor:

public FixSessionInfo[ ] GetFixSessionInfoCollection()

To identify the current session state for a particular FixSession, you need to pass the TargetCompID value from the corresponding FixSessionInfo object in the following function:

public eSessionState GetSessionState(string targetCompID)

  1. How do I set different messaging rules for different counterparties (Initiator sessions)?

The messaging rules for a session include supported message types and fields, message recovery rules and message validation levels.

The supported message types and fields can be identified using the FixDataDictionary object associated with the FixSession. The FixConfig object that is supplied as a parameter to the AcceptorTargetConfig constructor contains the associated FixDataDictionary object. The FixConfig object also includes the recovery and validation rules for messages.

After supplying different FixConfig objects for different counterparties, you can implement different messaging rules for each FixSession maintained by your Acceptor application.

For details about messaging rules, see FIX Configuration and FIX Data Dictionary.

  1. How do I logout a particular counterparty without affecting the transactions it made?

You can access the FixSession object for a particular session (counterparty) using the following function exposed by the Acceptor class:

public FixSession GetFixSession(string targetCompID)

Using the retrieved object, you can perform the logout and many other actions. The FixSession class documentation in FF.FIX Engine documentation provides further details on this topic.

  1. Does the Acceptor class provide help in order matching?

The Acceptor class in FF.FIX Engine is provided as a library and its implementation is restricted to abstracting out intricacies of FIX session maintenance and management. The Acceptor can notify the application about Application Messages received from different counterparties through callbacks on the FixAcceptorHandler object supplied during the Init() call of the Acceptor. After this, the application implementation has to appropriately process the received Application Messages, including the messages related to orders.

For details, see FIX Session Handler.

  1. How does my Acceptor application validate the credentials of a session initiating counterparty?

The responsibility of validating the credentials of session initiating counterparties lies with the Acceptor application. On receiving a Logon message from a session initiating counterparty, the Acceptor application invokes the OnLogonMessage callback on the FIXAcceptorHandler.

The following code snippet demonstrates a sample OnLogonMessage callback implementation:

//Verify the Logon message from an Initiator and send the counter-Logon message.

//If credentials are valid. Otherwise send Logout message.
string password = message.GetField(FixFieldTag.Password_554);

if(password != "FGH")
{
    //Invalid Logon, password mismatch, Send Logout message.
    FixMessage logoutFixMessage = fixSession.GetLogoutMessage("Invalid Password. Logout Forced");
    logoutFixMessage.SetField(789, "");
    fixSession.SendMessage(logoutFixMessage);
    return;
}

//Valid Logon, send Logon acknowledgment.
FixMessage fixLogonMessage = fixSession.GetSessionFixMessage("A");
fixLogonMessage.SetField(FixFieldTag.HeartBtInt_108, "30");
fixLogonMessage.SetField(FixFieldTag.EncryptMethod_98, "0");
fixSession.SendMessage(fixLogonMessage);

On successful execution of the last statement of above code, the Acceptor raises the NewFixSessionCreatedEvent event to notify the application about new FIX session creation.

  1. How can my Acceptor application know about the change of state of a FixSession maintained by it?

On any change in the session state, the Acceptor instance invokes the OnSessionStateChanged(FixSession fixSession, eSessionState sessionState) callback method on the FixAcceptorHandler object. This object is passed to the Acceptor instance as parameter during the Init() call.

The OnSessionStateChanged callback is limited only to the session state change notification. However, the Acceptor application can retrieve a FixSession corresponding to a specific counterparty and can register not only for the SessionStateChange alert but also for other alerts on it.

For example:

FixSessionState fixSessionState = _acceptor.GetFixSessionState(_acceptorTargetConfig.TargetCompID);

//Register to listen all session alerts
fixSessionState.GetAlertManager().RegisterAlertCallback(eAlertType.All, new AlertCallbackRoutine (OnFixSessionAlertMessage));
...
...
...

private void OnFixSessionAlertMessage(SessionInfo fixSessionInfo, eAlertType alertType, string alertMessage, string additionalMessage)
{
    switch (alertType)
    {
        case eAlertType.Error:
        ...
        ...
        ...

        break;
        case eAlertType.InboundMessage:
        ...
        ...
        ...

        break;
        case eAlertType.InboundMessageSeqNumber:
        ...
        ...
        ...

        break;
        case eAlertType.Info:
        ...
        ...
        ...

        break;
        case eAlertType.OutboundMessage:
        ...
        ...
        ...

        break;
        case eAlertType.OutboundMessageSeqNumber:
        ...
        ...
        ...

        break;
        case eAlertType.SessionStateChange:
        ...
        ...
        ...

        break;
        case eAlertType.Warning:
        ...
        ...
        ...

        break;
    }
}

  1. How do I use SSL?

Your Acceptor application can use SSL for its FIX connections with counterparties. For this purpose, set the SecurityOptions property of the Acceptor instance to provide SSL support as shown below:

private Acceptor _acceptor = new Acceptor();
SecurityOptions securityOptions = new SecurityOptions(eNetworkSecureProtocol.Ssl, eConnectionEnd.Server);
securityOptions.CertificateFile = "...";
//Provide Acceptor's SSL certificate file name. _acceptor.SecurityOptions = securityOptions;