I am working on the development of a solution to connect to a financial market using the FIX protocol with the quickfixj framework. Specifically I am implementing an initiator and I require to connect to the acceptor specify username and password. The quickfixj documentation is not very clear in this regard on how to pass these fields in the Logon message to the server.

Going through I found that it is put in the function toAdmin, I have put in this function the following code:

@Override
public void toAdmin(Message message, SessionID sessionId) {

    Session.lookupSession(sessionId).setTargetDefaultApplicationVersionID(new ApplVerID("9"));

    final Message.Header header = message.getHeader();      

     try {
        if ( header.getField(new BooleanField(MsgType.FIELD)).equals(MsgType.LOGON) ) {                  
                message.setField(new StringField(Username.FIELD, "user")); 
                message.setField( new StringField(Password.FIELD, "pass"));
                System.out.println(">>> " + message.toRawString()); 
             }
    } catch (FieldNotFound e) {
        // TODO Auto-generated catch block

        e.printStackTrace();
    } 
}

But I still can not do the Logon process and it shows me the next log when it tries the Logon.

<20190313-14:44:33, FIXT.1.1:aaa->bbb, outgoing> (8=FIXT.1.1 9=74 35=A 34=1 49=aaa 52=20190313-14:44:33.431 56=bbb 98=0 108=30 1137=9 10=131 )
<20190313-14:44:33, FIXT.1.1:aaa->bbb, event> (Initiated logon request)
<20190313-14:44:33, FIXT.1.1:aaa->bbb, event> (Disconnecting: Encountered END_OF_STREAM)
<20190313-14:44:37, FIXT.1.1:aaa->bbb, event> (MINA session created: local=/192.168.1.80:51372, class org.apache.mina.transport.socket.nio.NioSocketSession, remote=/3.3.3.3:443)
<20190313-14:44:38, FIXT.1.1:aaa->bbb, outgoing> (8=FIXT.1.1 9=74 35=A 34=2 49=aaa 52=20190313-14:44:38.420 56=bbb 98=0 108=30 1137=9 10=135 )
<20190313-14:44:38, FIXT.1.1:aaa->bbb, event> (Initiated logon request)
<20190313-14:44:38, FIXT.1.1:aaa->bbb, event> (Disconnecting: Encountered END_OF_STREAM)

In some forums they mention that this can take place when the username and password are not passed correctly

Questions:

  • Someone has used quickfixj passing username and password to
    authenticate in an acceptor that could help me.
  • The error message shown could have some other cause that someone knows?

1

Starting with QuickFIX/J 2.2.0 you are able to pass LogonTag session settings to have these tags set on the Logon message that is sent out.

Example:

LogonTag=553=user
LogonTag1=554=password 

6

This is what you need in your toAdmin():

final String msgType = msg.getHeader().getString(MsgType.FIELD);
if(MsgType.LOGON.compareTo(msgType) == 0)
{
    msg.setString(quickfix.fields.Username.FIELD, _username);
    msg.setString(quickfix.fields.Password.FIELD, _password);
}

This is in the User FAQ.

2