Skip to content

Compatibility Issue with Latest paho-mqtt Version and Adafruit_IO MQTT_Client Constructor #152

@thelizri

Description

@thelizri
  • Platform/operating system (i.e. Raspberry Pi with Raspbian operating system,
    Windows 32-bit, Windows 64-bit, Mac OSX 64-bit, etc.): MacOS Sonoma 14.0

  • Python version (run python -version or python3 -version): Python 3.11.5

  • Error message you are receiving, including any Python exception traces:
    Exception ignored in: <function Client.del at 0x10ed92160>
    Traceback (most recent call last):
    File "/Users/william/Documents/Internet of Things/wireless_power_transfer/.venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 874, in del
    self._reset_sockets()
    File "/Users/william/Documents/Internet of Things/wireless_power_transfer/.venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 1133, in _reset_sockets
    self._sock_close()
    File "/Users/william/Documents/Internet of Things/wireless_power_transfer/.venv/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 "/Users/william/Documents/Internet of Things/wireless_power_transfer/main.py", line 55, in
    client = MQTTClient(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/william/Documents/Internet of Things/wireless_power_transfer/.venv/lib/python3.11/site-packages/Adafruit_IO/mqtt_client.py", line 63, in init
    self._client = mqtt.Client()
    ^^^^^^^^^^^^^
    TypeError: Client.init() missing 1 required positional argument: 'callback_api_version'

  • List the steps to reproduce the problem below (if possible attach code or commands
    to run): I got this problem when running the mqtt_shared_feeds.py example. It appears the Adafruit_IO MQTT_Client is not compliant with the latest update of paho-mqtt. It works if I run an older version of paho-mqtt. For the newer version the constructor needs to be provided an CallbackAPIVersion. For example
    import paho.mqtt.client as mqtt
    mqttc = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions