OnixS C++ FIX Engine  3.24.0
API Documentation
Connecting using Custom Logon Message

As it is well-known, when a session is being established, it sends a Logon message, as it is defined by FIX Standard. However, in specific use contexts there may be a need to include additional information to the counterparty which is not specified by Standard. One of the common use case examples is when the counterparty requires authentication attributes like username and password. OnixS C++ FIX Engine supports this capability through the additional overload of the OnixS::FIX::Session class - OnixS::FIX::Session::logonAsInitiator.

If you use a custom Logon in OnixS::FIX::Session::logonAsInitiator method then this custom Logon will also be used when the FIX Engine automatically attempts to recover the FIX connection after some network related issues.


A lot of trading systems, based on version 4.2 of the FIX Protocol, require username (tag #553) and password (tag #554) fields to be included in the Logon message. Both fields do not exist in version 4.2 of the formal Standard. These fields were implemented in later versions of the FIX Protocol standards releases. The following sample demonstrates the solution for this typical situation. In particular, it sends the Logon message with the additional fields which are required by the counterparty.

using namespace OnixS::FIX;
using namespace OnixS::FIX::FIX43;
// Session attributes.
const string senderCompID = "CustomLogonMessage_SND";
const string targetCompID = "CustomLogonMessage_TRG";
const int HBI = 30;
const string username = "USER_NAME";
const string password = "PASSWORD";
// Connection settings.
const string host = "localhost";
int port = Engine::instance()->listenPort();
// Here we go..
ISessionListener defaultListener;
Session initiator(senderCompID, targetCompID, version, &defaultListener);
Message logonMsgWithAuthentication(Values::MsgType::Logon, version);
// Username, as well as Password field, was first invented in FIX 4.3.
// Therefore, tag value should be taken from a OnixS::FIX::FIX43 namespace.
logonMsgWithAuthentication.set(Tags::Username, username);
logonMsgWithAuthentication.set(Tags::Password, password);
initiator.logonAsInitiator(host, port, HBI, &logonMsgWithAuthentication);
// That's all special. Regular session manipulating goes afterwards..