Misleading error message when connecting to an MQTT 3 only broker with MQTT 5
Closed this issue · 1 comments
ahelmbr commented
Expected behavior
Handle error with a better exception
Actual behavior
Anjas-MacBook-Pro:hivemq-cli ahelmbre$ java -jar build/libs/mqtt-cli-1.0.0.jar pub -pw test -u anja -t test -m ";2Cmessage" -i test -d
Client test: sending CONNECT
Client test: com.hivemq.client.mqtt.mqtt5.exceptions.Mqtt5DisconnectException: Exception while decoding CONNACK: remaining length too short
at com.hivemq.client.internal.mqtt.MqttBlockingClient.connect(MqttBlockingClient.java:91)
at com.hivemq.cli.mqtt.MqttClientExecutor.mqtt5Connect(MqttClientExecutor.java:79)
at com.hivemq.cli.mqtt.AbstractMqttClientExecutor.connectMqtt5Client(AbstractMqttClientExecutor.java:238)
at com.hivemq.cli.mqtt.AbstractMqttClientExecutor.connect(AbstractMqttClientExecutor.java:201)
at com.hivemq.cli.mqtt.MqttClientExecutor.connect(MqttClientExecutor.java:62)
at com.hivemq.cli.mqtt.AbstractMqttClientExecutor.getMqttClientFromCacheOrConnect(AbstractMqttClientExecutor.java:432)
at com.hivemq.cli.mqtt.AbstractMqttClientExecutor.publish(AbstractMqttClientExecutor.java:110)
at com.hivemq.cli.mqtt.MqttClientExecutor.publish(MqttClientExecutor.java:62)
at com.hivemq.cli.commands.cli.PublishCommand.run(PublishCommand.java:109)
at picocli.CommandLine.executeUserObject(CommandLine.java:1729)
at picocli.CommandLine.access$900(CommandLine.java:145)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2101)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2068)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:1935)
at picocli.CommandLine.execute(CommandLine.java:1864)
at com.hivemq.cli.MqttCLIMain.main(MqttCLIMain.java:72)
Caused by: com.hivemq.client.mqtt.exceptions.MqttDecodeException: Exception while decoding CONNACK: remaining length too short
Client test: Exception while decoding CONNACK: remaining length too short
To Reproduce
- try to publish with an Mqtt 5 Client
- broker is set to a mosquitto broker
Steps
Reproducer code
Details
- Affected HiveMQ MQTT Client version(s): 1.1.2
- Used JVM version:1.8
SgtSilvio commented
The mosquitto broker is an old version which only supports MQTT 3.
The ConnAck is then an MQTT 3 ConnAck which has a shorter length (2) than MQTT 5 (3).