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

Documentation does not mention differences in constructor/callback parameters for MQTTv5

Open smuskiew opened this issue 3 years ago • 1 comments

It seems like the pydocs for paho-mqtt are missing a few details regarding the MQTTv5 protocol:

  • The on_connect() callback handler appears to need an additional properties parameter when used with v5. However the pydocs don't mention this at all which leads to a confusing exception: TypeError: _on_connect() takes 5 positional arguments but 6 were given
  • It looks like the Client() constructor doesn't support/allow the clean_session parameter at all with v5. Although the exception does make this clear (ValueError: Clean session is not used for MQTT 5.0) this is not mentioned at all in the pydocs for the constructor.

Is it possible to update the pydocs to reflect the above for v5?

smuskiew avatar Feb 09 '22 00:02 smuskiew

This issue priority should be the highest. API documents must be correct. Some tutorials on Internet are updated with MQTTv5 but the number of arguments is still 5. http://www.steves-internet-guide.com/python-mqtt-client-changes/

  • Confusing error when using the old example for connecting
    raise ValueError('Clean session is not used for MQTT 5.0')
ValueError: Clean session is not used for MQTT 5.0
  • Error on on_connect() callback
    on_connect(self, self._userdata,
TypeError: func_on_connect_cb() takes from 4 to 5 positional arguments but 6 were given

quocneo avatar Jun 22 '23 21:06 quocneo