Skip to content

Commit d82e862

Browse files
authored
[PATCH] support for paho.mqtt.python 2.0.0 (#211)
1 parent 499237d commit d82e862

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/wiotp/sdk/client.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,13 @@ def __init__(
128128
pahoVersion,
129129
wiotpVersion,
130130
)
131-
self.client = paho.Client(self.clientId, transport=transport, clean_session=(not cleanStart))
131+
132+
# paho 2.0.0 has a breaking change for callbacks to support both 2.0.0 and 1.x we need
133+
# to create a client in version1 mode if using 2.0.0
134+
if pahoVersion >= "2.0.0":
135+
self.client = paho.Client(paho.CallbackAPIVersion.VERSION1, self.clientId, transport=transport, clean_session=(not cleanStart))
136+
else:
137+
self.client = paho.Client(self.clientId, transport=transport, clean_session=(not cleanStart))
132138

133139
# Normal usage puts the client in an auto-detect mode, where it will try to use
134140
# TLS, and fall back to unencrypted mode ONLY if TLS 1.2 is unavailable.

0 commit comments

Comments
 (0)