title: How to properly connect with authentication in HiveMQ?
body: <p>I'm trying to connect a client to a server with simple authentication using HiveMQ. On HiveMQ Client I created a client and used the <code>connectWith()</code> to specify that I want to connect with simple authentication. When I inputted a username and password I get a <code>MqttClientStateException</code> which I left below. Am I supposed to store/configure a username and password manually on the server as I just inputted a <code>username</code> and <code>password</code> like the tutorial here: </p>
  
  <p><a href="https://hivemq.github.io/hivemq-mqtt-client/docs/mqtt_operations/connect.html#authenticationauthorization" rel="nofollow noreferrer">https://hivemq.github.io/hivemq-mqtt-client/docs/mqtt_operations/connect.html#authenticationauthorization</a> . </p>
  
  <p>Code: </p>
  
  <pre><code>Mqtt5BlockingClient publisher = Mqtt5Client.builder()
      .identifier(UUID.randomUUID().toString()) // the unique identifier of the MQTT client. The ID is randomly generated between 
      .serverHost("localhost")  // the host name or IP address of the MQTT server. Kept it localhost for testing. localhost is default if not specified.
      .serverPort(1883)  // specifies the port of the server
      .addConnectedListener(context -&gt; ClientConnectionRetreiver.printConnected("Publisher1"))         // prints a string that the client is connected
      .addDisconnectedListener(context -&gt; ClientConnectionRetreiver.printDisconnected("Publisher1"))  // prints a string that the client is disconnected
      .buildBlocking();  // creates the client builder                
      publisher.connectWith() // connects the client
          .simpleAuth()
              .username("Username")
              .password("Password".getBytes())
              .applySimpleAuth();
  </code></pre>
  
  <p>Exception: </p>
  
  <pre><code>Exception in thread "SubThread1" com.hivemq.client.mqtt.exceptions.MqttClientStateException: MQTT client is not connected.
  at com.hivemq.client.internal.mqtt.MqttBlockingClient.subscribe(MqttBlockingClient.java:101)
  at com.hivemq.client.internal.mqtt.message.subscribe.MqttSubscribeBuilder$Send.send(MqttSubscribeBuilder.java:184)
  at com.main.SubThread.run(SubThread.java:83)
  at java.base/java.lang.Thread.run(Thread.java:834)
  </code></pre>