title: QuickFIX/J Initiator - setup username and password at Logon
body: <p>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.</p>
  
  <p>Going through I found that it is put in the function toAdmin, I have put in this function the following code:</p>
  
  <pre><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("&gt;&gt;&gt; " + message.toRawString()); 
               }
      } catch (FieldNotFound e) {
          // TODO Auto-generated catch block
  
          e.printStackTrace();
      } 
  }
  </code></pre>
  
  <p>But I still can not do the Logon process and it shows me the next log when it tries the Logon.</p>
  
  <pre><code>&lt;20190313-14:44:33, FIXT.1.1:aaa-&gt;bbb, outgoing&gt; (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 )
  &lt;20190313-14:44:33, FIXT.1.1:aaa-&gt;bbb, event&gt; (Initiated logon request)
  &lt;20190313-14:44:33, FIXT.1.1:aaa-&gt;bbb, event&gt; (Disconnecting: Encountered END_OF_STREAM)
  &lt;20190313-14:44:37, FIXT.1.1:aaa-&gt;bbb, event&gt; (MINA session created: local=/192.168.1.80:51372, class org.apache.mina.transport.socket.nio.NioSocketSession, remote=/3.3.3.3:443)
  &lt;20190313-14:44:38, FIXT.1.1:aaa-&gt;bbb, outgoing&gt; (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 )
  &lt;20190313-14:44:38, FIXT.1.1:aaa-&gt;bbb, event&gt; (Initiated logon request)
  &lt;20190313-14:44:38, FIXT.1.1:aaa-&gt;bbb, event&gt; (Disconnecting: Encountered END_OF_STREAM)
  </code></pre>
  
  <p>In some forums they mention that this can take place when the username and password are not passed correctly</p>
  
  <p>Questions:</p>
  
  <ul>
  <li>Someone has used quickfixj passing username and password to
  authenticate in an acceptor that could help me. </li>
  <li>The error message shown could have some other cause that someone knows?</li>
  </ul>