3

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?
Christoph John
  • 3,003
  • 2
  • 13
  • 23

2 Answers2

8

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 
Christoph John
  • 3,003
  • 2
  • 13
  • 23
  • Please can you give more details? this is not working for me – user666 Jun 10 '21 at 10:13
  • 1
    This is definitely working. Are you sure you are using QuickFIX/J (i.e. the **Java** port) in at least version 2.2.0? – Christoph John Jun 10 '21 at 10:27
  • i am using wso2, when i try to upgrade to 2.2.0 i get the following error: quickfix.ConfigError: FIX44.xml: Property 'http://javax.xml.XMLConsta nts/property/accessExternalDTD' is not recognized. and the logon message is not even sent, but with the older version the username is not read but the logon command is sent. – user666 Jun 10 '21 at 12:11
  • 1
    The error message is a bug in 2.2.0. Please try 2.3.0 – Christoph John Jun 10 '21 at 12:17
  • it worked fine thank you i can see the username and password in the fix command. However i am still getting a logout response: Required tag missing, field=553 (while 553 is present in the message) do you have any idea why? – user666 Jun 10 '21 at 12:53
  • No. But your counter party should be able to tell you the reason. – Christoph John Jun 10 '21 at 13:10
5

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.

Grant Birchmeier
  • 17,809
  • 11
  • 63
  • 98