hivemq / mqtt-cli

MQTT CLI is a useful command line interface for connecting various MQTT clients supporting MQTT 5.0 and 3.1.1
https://hivemq.github.io/mqtt-cli/
Apache License 2.0
316 stars 47 forks source link

Cannot connect to AWS IoT core: "Exception while decoding CONNACK: remaining length too short" #284

Closed alex-vovk closed 1 year ago

alex-vovk commented 2 years ago

Expected behavior

Connected to the AWS IoT Core and subscribed to the topic.

Actual behavior

Connection fails. The following output is provided:

Client 'UNKNOWN@private-endpoint.iot.us-east-1.amazonaws.com' sending CONNECT MqttConnect{keepAlive=60, cleanStart=true, sessionExpiryInterval=0}
Client 'UNKNOWN@private-endpoint.iot.us-east-1.amazonaws.com' DISCONNECTED Exception while decoding CONNACK: remaining length too short
Exception while decoding CONNACK: remaining length too short

To Reproduce

Steps

Run from the terminal: mqtt-cli.exe subscribe --topic "#" --showTopics --host private-endpoint.us-east-1.amazonaws.com --port 8883 --secure --cert certificate.pem.crt --key private.pem.key --verbose --debug

Reproducer code

Details

Workaround

Add switch to MQTT 3 and set QOS to 0 by adding the following parameters: '--mqttVersion 3 --qos 0' For example: mqtt-cli.exe subscribe --topic "#" --showTopics --host private-endpoint.us-east-1.amazonaws.com --port 8883 --secure --cert certificate.pem.crt --key private.pem.key --verbose --debug --mqttVersion 3 --qos 0

MicWalter commented 1 year ago

I'm closing this issue as at the time where you reported this issue AWS IoT core did not support MQTT5 and you ran into this issue: https://github.com/hivemq/hivemq-mqtt-client/issues/327

As AWS added MQTT 5 support it should work now