OnixS C++ FIX Engine  4.10.1
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;
class SessionListener : public ISessionListener
void onInboundApplicationMsg(Message & message, Session *) ONIXS_FIXENGINE_OVERRIDE
// Processing incoming application-level message..
<< "Incoming application-level message: "
<< message.toString()
<< std::endl;
// Session attributes.
const std::string SenderCompID = "CustomLogonMessage_SND";
const std::string TargetCompID = "CustomLogonMessage_TRG";
const int Hbi = 30;
const std::string Username = "USER_NAME";
const std::string Password = "PASSWORD";
// Connection settings.
const std::string Host = "localhost";
const int Port = Engine::instance()->listenPort();
// Here we go..
SessionListener defaultListener;
Session initiator(SenderCompID, TargetCompID, Version, &defaultListener);
Message logonMsgWithAuthentication(OnixS::FIX::FIX40::Values::MsgType::Logon, Version);
// User-name, 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)
.set(Tags::Password, Password);
initiator.logonAsInitiator(Host, Port, Hbi, &logonMsgWithAuthentication);
// That's all special. Regular session manipulating goes afterwards..