title: MQTT5 message is lost on HiveMQ Cloud when correlationData is added
body: <p>In a Java server application, we want to use the correlationData, which is part of MQTT5, so we can use this in the reply message to link and validate it when the reply is received.</p>
  <p>I'm using the hivemq-mqtt-client library 1.2.2 and connecting to HiveMQ Cloud.</p>
  <p>The connection is made like this:</p>
  <pre><code>private Mqtt5AsyncClient client;
  
  public MqttConfig(Environment environment) {
      client = MqttClient.builder()
              .useMqttVersion5()
              .identifier(&quot;TestServer&quot;)
              .serverHost(MQTT_SERVER)
              .serverPort(MQTT_PORT)
              .sslWithDefaultConfig()
              .automaticReconnectWithDefaultConfig()
              .buildAsync();
  
      client.connectWith()
              .simpleAuth()
              .username(MQTT_USER)
              .password(MQTT_PASSWORD.getBytes())
              .applySimpleAuth()
              .send()
              .whenComplete((connAck, throwable) -&gt; {
                  if (throwable != null) {
                      logger.error(&quot;Could not connect to MQTT: {}&quot;, throwable.getMessage());
                  } else {
                      logger.info(&quot;Connected to MQTT: {}&quot;, connAck.getReasonCode());
                  }
              });
  }
  
  public Mqtt5AsyncClient getClient() {
      return client;
  }
  </code></pre>
  <p>Sending a message is done with this method:</p>
  <pre><code>mqttConfig.getClient()
              .publishWith()
              .topic(destinationTopic)
              //.correlationData(correlationData.getBytes())
              .responseTopic(responseTopic)
              .payload(message.getBytes())
              .qos(MqttQos.AT_LEAST_ONCE)
              .send()
              .whenComplete((result, throwable) -&gt; {
                  if (throwable != null) {
                      logger.info(&quot;Error sending to '{}': {} - {}&quot;, destinationTopic, message, throwable.getMessage());
                  } else {
                      logger.info(&quot;Message sent to '{}': {} - {}&quot;, destinationTopic, message, result);
                  }
              });
  </code></pre>
  <p>When monitoring the messages on <a href="http://www.hivemq.com/demos/websocket-client/" rel="nofollow noreferrer">http://www.hivemq.com/demos/websocket-client/</a> and on a subscriber, messages are only received when the line with `correlationData()' is commented, as you can see above.</p>
  <p>Both with or without that line, the application logs a successful sending, e.g. with correlation data enabled:</p>
  <pre><code>Message sent to 'server/test': testMessage - MqttQos2Result{publish=MqttPublish{topic=server/test, payload=11byte, qos=EXACTLY_ONCE, retain=false, responseTopic=server/test/reply, correlationData=6byte}, pubRec=MqttPubRec{packetIdentifier=1}}
  </code></pre>
  <p>Any idea why the additional correlationData seems to cause that they are not shown on the websocket test page, and are not received on any of the subscribers?</p>
  <p>As an experiment, I used the paho 5 library instead of the HiveMQ library with the following code, but had exactly the same behavior and needed to disable the line to see messages passing:</p>
  <pre><code>    MqttProperties properties = new MqttProperties();
      //properties.setCorrelationData(correlationData.getBytes());
      MqttMessage mqttMessage = new MqttMessage();
      mqttMessage.setQos(1);
      mqttMessage.setPayload(message.getBytes());
      mqttMessage.setProperties(properties);
      try {
          mqttConfig.getClient().publish(destinationTopic, mqttMessage);
          logger.info(&quot;Message was sent to '{}': {}&quot;, destinationTopic, message);
      } catch (MqttException ex) {
          logger.error(&quot;Error sending to '{}': {} - {}&quot;, destinationTopic, message, ex.getMessage());
      }
  </code></pre>