Open tiolan opened 3 years ago
The documentation says this about the on_disconnect rc value:
* rc - integer value indicating the reason for the disconnect. A value of 0
* means the client has called <mosquitto_disconnect>. Any other value
* indicates that the disconnect is unexpected.
In other words, you shouldn't rely on taking any meaning from the error condition, other than that it is an error. Now in practice there is meaning to the value. Prior to MQTT v5, it was a mosquitto error code. Since 1.6, MQTT v5 connections also have it set to an MQTT v5 reason code in some situations.
I think for 2.1 it can change so that the values are specified, and it is possible to distinguish between a Mosquitto error code and an MQTT reason code.
Mosquitto error code 7 is MOSQ_ERR_CONN_LOST
, connection lost.
I have the following setup:
I set the disconnect callback (it is in C++)
When trying to connect to the broker
mosquitto_connect_async
returnsERROR_TLS
(expected) andonDisconnectCb
is invoked (expected, wrong certificate).the field
mqttRc
is in this case set to 7.I do not find any definition for an mqtt5_reason code 7. https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901031 https://github.com/eclipse/mosquitto/blob/a33c28cfe19261b8c3856df88b1d4827055abc71/include/mqtt_protocol.h#L127
Did I misunderstand the API and this field is not always the mqtt5_reason code?