mqtt2sql icon indicating copy to clipboard operation
mqtt2sql copied to clipboard

paho 2.x

Open redbug26 opened this issue 1 year ago • 4 comments

Describe the bug

After upgrading to paho-mqtt version 2.x, I encountered the following error:

ValueError: Unsupported callback API version: version 2.0 added a callback_api_version, see docs/migrations.rst for details

While I understand from the error that a callback_api_version parameter is now required.

Suggested Fix

mqttc = mqtt.Client('{}-{:d}'.format(SCRIPTNAME, os.getpid()), clean_session=True, userdata=self.userdata, protocol=mqtt.MQTTv31, mqtt.CallbackAPIVersion.VERSION1)

in place of

mqttc = mqtt.Client('{}-{:d}'.format(SCRIPTNAME, os.getpid()), clean_session=True, userdata=self.userdata, protocol=mqtt.MQTTv31)

As described on https://eclipse.dev/paho/files/paho.mqtt.python/html/migrations.html

redbug26 avatar May 25 '25 08:05 redbug26

I have alerady noticed the issue too and have previously tried the same suggestionvas yours, which as far as I remember is not backwards compatible with the old paho, currently can't test it again.

Did you checked if your suggestion is working also with the previous paho?

curzon01 avatar May 27 '25 10:05 curzon01

No, I haven’t tested it — that’s actually why I didn’t submit a pull request yet 🙂 On my machine, I simply worked around it with: pip install paho-mqtt==1.6.1 But I’ll do some proper testing for both versions and send a PR accordingly.

redbug26 avatar May 27 '25 11:05 redbug26

Thx, that would be good (unfortunately I can't access my developer environment at the moment), take your time. Use a Python venv to test different lib versions before you install old libs with pip.

curzon01 avatar May 27 '25 19:05 curzon01

Using mqtt.CallbackAPIVersion.VERSION1 is not backward compatible (paho-mqtt 2.x changes are breaking changes) so this solution should solve any issues with different paho-mqtt

curzon01 avatar Jun 22 '25 10:06 curzon01