Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mqttwarn does not like py39-paho-mqtt-2.0.0 #694

Open
dlangille opened this issue Mar 2, 2024 · 12 comments
Open

mqttwarn does not like py39-paho-mqtt-2.0.0 #694

dlangille opened this issue Mar 2, 2024 · 12 comments

Comments

@dlangille
Copy link
Contributor

I've been unable to get mqttwarn to start today after updating py39-paho-mqtt: 1.6.1 -> 2.0.0

Reverting to 1.6.1 gets it running again.

Seem related to https://stackoverflow.com/questions/77984857/paho-mqtt-unsupported-callback-api-version-error?noredirect=1

[12:20 mqtt01 dvl /usr/local/etc/rc.d] % sudo /usr/local/bin/mqttwarn --config-file=/usr/local/etc/mqttwarn/mqttwarn.ini
2024-03-02 12:20:58,853 INFO     [mqttwarn.commands         ] Starting mqttwarn
2024-03-02 12:20:58,853 INFO     [mqttwarn.commands         ] Log level is DEBUG
2024-03-02 12:20:58,853 DEBUG    [mqttwarn.core             ] Trying to load built-in service "file" from "file"
2024-03-02 12:20:58,854 DEBUG    [mqttwarn.core             ] Trying to load service "file" from file "/usr/local/lib/python3.9/site-packages/mqttwarn/services/file.py"
2024-03-02 12:20:58,855 INFO     [mqttwarn.core             ] Successfully loaded service "file"
2024-03-02 12:20:58,855 DEBUG    [mqttwarn.core             ] Trying to load built-in service "pushover" from "pushover"
2024-03-02 12:20:58,855 DEBUG    [mqttwarn.core             ] Trying to load service "pushover" from file "/usr/local/lib/python3.9/site-packages/mqttwarn/services/pushover.py"
2024-03-02 12:20:58,985 INFO     [mqttwarn.core             ] Successfully loaded service "pushover"
2024-03-02 12:20:58,986 DEBUG    [mqttwarn.core             ] Trying to load built-in service "log" from "log"
2024-03-02 12:20:58,986 DEBUG    [mqttwarn.core             ] Trying to load service "log" from file "/usr/local/lib/python3.9/site-packages/mqttwarn/services/log.py"
2024-03-02 12:20:58,986 INFO     [mqttwarn.core             ] Successfully loaded service "log"
Traceback (most recent call last):
  File "/usr/local/bin/mqttwarn", line 8, in <module>
    sys.exit(run())
  File "/usr/local/lib/python3.9/site-packages/mqttwarn/commands.py", line 93, in run
    run_mqttwarn(configfile=options["--config-file"])
  File "/usr/local/lib/python3.9/site-packages/mqttwarn/commands.py", line 155, in run_mqttwarn
    subscribe_forever()
  File "/usr/local/lib/python3.9/site-packages/mqttwarn/core.py", line 688, in subscribe_forever
    mqttc = connect()
  File "/usr/local/lib/python3.9/site-packages/mqttwarn/core.py", line 642, in connect
    mqttc = paho.Client(cf.clientid, clean_session=cf.cleansession, protocol=cf.protocol)
  File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 766, in __init__
    raise ValueError(
[12:20 mqtt01 dvl /usr/local/etc/rc.d] % sudo /usr/local/bin/mqttwarn --config-file=/usr/local/etc/mqttwarn/mqttwarn.ini
2024-03-02 12:20:58,853 INFO     [mqttwarn.commands         ] Starting mqttwarn
2024-03-02 12:20:58,853 INFO     [mqttwarn.commands         ] Log level is DEBUG
2024-03-02 12:20:58,853 DEBUG    [mqttwarn.core             ] Trying to load built-in service "file" from "file"
2024-03-02 12:20:58,854 DEBUG    [mqttwarn.core             ] Trying to load service "file" from file "/usr/local/lib/python3.9/site-packages/mqttwarn/services/file.py"
2024-03-02 12:20:58,855 INFO     [mqttwarn.core             ] Successfully loaded service "file"
2024-03-02 12:20:58,855 DEBUG    [mqttwarn.core             ] Trying to load built-in service "pushover" from "pushover"
2024-03-02 12:20:58,855 DEBUG    [mqttwarn.core             ] Trying to load service "pushover" from file "/usr/local/lib/python3.9/site-packages/mqttwarn/services/pushover.py"
2024-03-02 12:20:58,985 INFO     [mqttwarn.core             ] Successfully loaded service "pushover"
2024-03-02 12:20:58,986 DEBUG    [mqttwarn.core             ] Trying to load built-in service "log" from "log"
2024-03-02 12:20:58,986 DEBUG    [mqttwarn.core             ] Trying to load service "log" from file "/usr/local/lib/python3.9/site-packages/mqttwarn/services/log.py"
2024-03-02 12:20:58,986 INFO     [mqttwarn.core             ] Successfully loaded service "log"
Traceback (most recent call last):
  File "/usr/local/bin/mqttwarn", line 8, in <module>
    sys.exit(run())
  File "/usr/local/lib/python3.9/site-packages/mqttwarn/commands.py", line 93, in run
    run_mqttwarn(configfile=options["--config-file"])
  File "/usr/local/lib/python3.9/site-packages/mqttwarn/commands.py", line 155, in run_mqttwarn
    subscribe_forever()
  File "/usr/local/lib/python3.9/site-packages/mqttwarn/core.py", line 688, in subscribe_forever
    mqttc = connect()
  File "/usr/local/lib/python3.9/site-packages/mqttwarn/core.py", line 642, in connect
    mqttc = paho.Client(cf.clientid, clean_session=cf.cleansession, protocol=cf.protocol)
  File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 766, in __init__
    raise ValueError(
ValueError: Unsupported callback API version: version 2.0 added a callback_api_version, see migrations.md for details
@jpmens
Copy link
Collaborator

jpmens commented Mar 2, 2024 via email

@adequacy1
Copy link

adequacy1 commented Mar 25, 2024

core.py:

- mqttc = paho.Client(cf.clientid, clean_session=cf.cleansession, protocol=cf.protocol)
+ mqttc = paho.Client(paho.CallbackAPIVersion.VERSION1, cf.clientid, clean_session=cf.cleansession, protocol=cf.protocol)

@jpmens
Copy link
Collaborator

jpmens commented Mar 25, 2024 via email

@amotl
Copy link
Member

amotl commented Mar 27, 2024

omg. Thanks for letting us know, and apologies for the late reply. We will take corresponding steps to remedy the problem in one way or another.

Paho™ MQTT Python v2.0.0, released on Feb 10 2024, includes breaking changes. See migration instructions for more details on how to upgrade. The release also introduces new documentation available online.

-- https://github.com/eclipse/paho.mqtt.python/releases/tag/v2.0.0

@amotl
Copy link
Member

amotl commented Mar 28, 2024

At least the dependency version pinning in project metadata is right. So, when package managers are taking them into account, nothing should break from one day to the other accidentally?

"paho-mqtt<2",

NB: I am just trying to assess the seriousness and impact of the issue. @dlangille: Did you upgrade py39-paho-mqtt to the next major version deliberately, or did it happen automatically? Is it possible for BSD to have both versions at the same time, or are you currently destined to exclusively run the previous version of paho mqtt, because of this situation, while you actually would like to upgrade?

@amotl
Copy link
Member

amotl commented Mar 28, 2024

@dlangille: Relaying the error you reported....

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

... it probably relates to the topmost item from the v2.0.0 release notes:

Caution

BREAKING: Added callback_api_version. This breaks ALL users of paho-mqtt's Client class.

See migrations.rst for details on how to upgrade.
tl; dr; add CallbackAPIVersion.VERSION1 to first argument of Client().

Fixing this sounds easy.

@amotl
Copy link
Member

amotl commented Mar 28, 2024

@amotl
Copy link
Member

amotl commented Mar 29, 2024

I've just submitted a patch to remedy the breaking change on the most prominent spot, based on learnings from mqtt-tools/pytest-mqtt#18.

However, I don't think that patch will be accepted, as the authors seem to pretty strong about this detail?

@amotl
Copy link
Member

amotl commented Apr 7, 2024

Hi. It looks like my patch might get accepted, helping users in basic use case scenarios to upgrade to Paho MQTT client version 2 without a breaking change. Naturally, it will not work in more advanced cases, as outlined by @PierreF on the same discussion. Thanks!

@amotl
Copy link
Member

amotl commented Apr 22, 2024

It looks like paho-mqtt v2 is causing serious havoc throughout the community. That is natural with breaking changes, and apparently, much of what is behind is about the proper transitioning to support MQTTv5, which makes things different under the hood.

However, I did not dig deeper, and, in this spirit, I am not able to evaluate the situation better than submitting that humble patch, and hoping for the best outcomes in the long run. That such an event feels annoying, is perfectly reasonable. However, sometimes such changes must happen, and all we can take away from that is that all users of packages should apply version pinning properly, in order not to run into such situations. In this case, paho-mqtt<2.

@amotl
Copy link
Member

amotl commented Apr 22, 2024

For mqttwarn, I think it is sensible to wait for any further changes happen on paho-mqtt. Because mqttwarn is correctly applying the version pinning, I guess there is not much else to do at this point in time? Please let us know if you think differently.

"paho-mqtt<2",

@dlangille
Copy link
Contributor Author

Have you tried 2.1.0? I did, yesterday, no luck for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants