Skip to content

Commit

Permalink
[PATCH] support for paho.mqtt.python 2.0.0 (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanBoden authored Jun 18, 2024
1 parent 499237d commit d82e862
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/wiotp/sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit d82e862

Please sign in to comment.