From d82e86252207d5fb500c08249fa1822ee30260c8 Mon Sep 17 00:00:00 2001 From: Ian Boden <82514609+IanBoden@users.noreply.github.com> Date: Tue, 18 Jun 2024 16:17:26 +0100 Subject: [PATCH] [PATCH] support for paho.mqtt.python 2.0.0 (#211) --- src/wiotp/sdk/client.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/wiotp/sdk/client.py b/src/wiotp/sdk/client.py index dd9b6ff..869727f 100644 --- a/src/wiotp/sdk/client.py +++ b/src/wiotp/sdk/client.py @@ -128,7 +128,13 @@ def __init__( pahoVersion, wiotpVersion, ) - self.client = paho.Client(self.clientId, transport=transport, clean_session=(not cleanStart)) + + # paho 2.0.0 has a breaking change for callbacks to support both 2.0.0 and 1.x we need + # to create a client in version1 mode if using 2.0.0 + if pahoVersion >= "2.0.0": + self.client = paho.Client(paho.CallbackAPIVersion.VERSION1, self.clientId, transport=transport, clean_session=(not cleanStart)) + else: + self.client = paho.Client(self.clientId, transport=transport, clean_session=(not cleanStart)) # Normal usage puts the client in an auto-detect mode, where it will try to use # TLS, and fall back to unencrypted mode ONLY if TLS 1.2 is unavailable.