How do I read the connack returnCode

I am using a ewon flexy 202 and when I try to connect to hivemq I see in the log a connect message sent, a connack message recived, then the mqtt disconnected unexpectedly. I think I have already set all the parameter correctly so I need to see the return code in the connack package so I can pin point where I am geting rejected by the broker thanks

my code

MQTT "open", "client_name", "broker_URL"
MQTT "setparam", "log", "1" // printing of the client verbose logs in the Realtime Log event of the device.
MQTT "setparam", "port", "8883"
MQTT "setparam", "username", "Mqtt-username"
MQTT "setparam", "password", "Mqtt-userpassword"
MQTT "setparam", "cafile", "/usr/root.pem"
MQTT "setparam", "ProtocolVersion", "3.1.1"
MQTT "setparam", "TLSVersion", "tlsv1.2"
MQTT "connect"

Hello @mushroom ,

very nice that you are interested in MQTT and HiveMQ!

Support of CONNACK packet with return code is introduced in MQTT v 3.1.1 specification (MQTT Version 3.1.1). In order to use this feature both your MQTT Client (library) and broker should support the MQTT v 3.1.1 standard.

  • What is your MQTT broker?
  • Did you try to test connection to the broker using a different client, like MQTT CLI?

Try to test your connect credentials with MQTT CLI and see which response code the broker returns. Use MQTT CLI with --debug and/or --verbose flag to get more insight into broker’s responses.

Kind regards,
Dasha from HiveMQ team

Hello thanks for the quick reply

I am using your free hivemq cloud broker

I can connect localy and also using multiple client connections(home assistant node red) only the ewon flexy 202 can’t connect to your cloud system

So I am asking how do I find the connect message on your broker(CONNACK package) to find out how it is being rejected and to debug it

Hi @mushroom ,

Thank you for clarifying your question. For decoding the MQTT 3.1.1 CONNACK packet you can refer to the following specification:

I hope this helps you to decode the packet and extract the response code from it
Kind regards,
Dasha from HiveMQ team