Seite 1 von 1

MQTT Problem

Verfasst: Dienstag 13. Februar 2024, 10:30
von Sams2024
Hallo zusammen habe ein MQTT Problem.

import paho.mqtt.client as mqtt
client = mqtt.Client()
client.connect("ip", 1883, 60)
in IP seht die richtige Nummer!

Exception ignored in: <function Client.__del__ at 0x000002CA9EC17240>
Traceback (most recent call last):
File "C:\Users\ich\AppData\Local\Programs\Python\Python312\Lib\site-packages\paho\mqtt\client.py", line 874, in __del__
self._reset_sockets()
File "C:\Users\ich\AppData\Local\Programs\Python\Python312\Lib\site-packages\paho\mqtt\client.py", line 1133, in _reset_sockets
self._sock_close()
File "C:\Users\ich\AppData\Local\Programs\Python\Python312\Lib\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 "d:\Python3_VS\mqtt_senden.py", line 3, in <module>
client = mqtt.Client()
^^^^^^^^^^^^^
TypeError: Client.__init__() missing 1 required positional argument: 'callback_api_version'
PS D:\Python3_VS>
Frage was ist der Grund für den Fehler, was muss ich machen damit es Funktioniert?

Re: MQTT Problem

Verfasst: Dienstag 13. Februar 2024, 10:39
von Sirius3
Der Grund steht ja in der Fehlermeldung: es fehlt ein zwingendes Argument, die callback-API-Version, wahrscheinlich `mqtt.CallbackAPIVersion.VERSION2`

Re: MQTT Problem

Verfasst: Dienstag 13. Februar 2024, 10:43
von Sams2024
Dankeschön für die Hilfe!
Hast du Bitte ein Beispiel wie es richtiger ist

Re: MQTT Problem

Verfasst: Dienstag 13. Februar 2024, 11:57
von Sirius3
Das findest Du in der Dokumentation.

Re: MQTT Problem

Verfasst: Mittwoch 14. Februar 2024, 00:12
von Sams2024
Paho Python MQTT gibt es jetzt als Version 2.0.0 seit dem 11. Februar 2024 und laufen nicht mit v1.x zusammen