maholli / PY4_gs

https://maholli.github.io/PY4_gs/
MIT License
2 stars 0 forks source link

paho_mqtt current default version (2.0) breaks project code (work-around provided) #3

Open K4KDR opened 9 months ago

K4KDR commented 9 months ago

It seems that the current default version of paho_mqtt is not compatible with the project code as it currently exists.

After installing the dependencies for py4_rx_mqtt.py (i.e., pip install msgpack paho-mqtt numpy), the following error results:

k4kdr@PY4-rpi:~/PY4_gs/rx_only $ python py4_rx_mqtt.py 
Exception ignored in: <function Client.__del__ at 0x7f83947060>
Traceback (most recent call last):
  File "/home/k4kdr/.local/lib/python3.11/site-packages/paho/mqtt/client.py", line 874, in __del__
    self._reset_sockets()
  File "/home/k4kdr/.local/lib/python3.11/site-packages/paho/mqtt/client.py", line 1133, in _reset_sockets
    self._sock_close()
  File "/home/k4kdr/.local/lib/python3.11/site-packages/paho/mqtt/client.py", line 1119, in _sock_close
    if not self._sock:
           ^^^^^^^^^^
AttributeError: 'Client' object has no attribute '_sock'
Traceback (most recent call last):
  File "/home/k4kdr/PY4_gs/rx_only/py4_rx_mqtt.py", line 38, in <module>
    mqttc = mqtt.Client(client_id=GROUND_STATION_ID)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Client.__init__() missing 1 required positional argument: 'callback_api_version'

... numerous online posts discuss the cause. For example:

https://community.openenergymonitor.org/t/emonhub-breaking-change-for-paho-mqtt/25580

... following their suggestion to downgrade to v1.6.1:

k4kdr@PY4-rpi:~/PY4_gs/rx_only $ pip install --upgrade paho-mqtt==1.6.1
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting paho-mqtt==1.6.1
  Downloading https://www.piwheels.org/simple/paho-mqtt/paho_mqtt-1.6.1-py3-none-any.whl (75 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 75.6/75.6 kB 406.4 kB/s eta 0:00:00
Installing collected packages: paho-mqtt
  Attempting uninstall: paho-mqtt
    Found existing installation: paho-mqtt 2.0.0
    Uninstalling paho-mqtt-2.0.0:
      Successfully uninstalled paho-mqtt-2.0.0
Successfully installed paho-mqtt-1.6.1

... the py4_rx_mqtt.py script runs without error. So, you may wish to either change the syntax for installing paho-mqtt to:

pip install --upgrade paho-mqtt==1.6.1

... or do whatever is required to become compatible with paho-mqtt v2.0

k4kdr@PY4-rpi:~/PY4_gs/rx_only $ python py4_rx_mqtt.py 
Testing mqtt broker connection...
    Success
Listening for UHF packets...

Best regards, --Scott, K4KDR

maholli commented 9 months ago

wow that's unexpected. Thanks for finding this! I'll implement your proposed version definition.