paho.mqtt.python icon indicating copy to clipboard operation
paho.mqtt.python copied to clipboard

Confusion about ReasonCode in MQTTv5

Open mindrunner opened this issue 3 years ago • 0 comments

I moved to MQTTv5 and updated the callbacks on_connect and on_disconnect

It seem that on_connect now passes me a ReasonCode object instead of an int. However, on_disconnect still uses int as rc. Is that on purpose or am I missing something here. I skimmed through the client.py code and it looks pretty much intentional.

Reading https://github.com/eclipse/paho.mqtt.python/issues/392, it seems like rc in on_disconnect has no real meaning, but then why do I find DISCONNECT in PacketTypes as well as several ReasonCodes for disconnect?

Most importantly, how do I find out why the connection was disconnected? Am I supposed to use error_string(rc) for that?

mindrunner avatar May 09 '22 14:05 mindrunner