From 0d502bf175a67f79f0aee9b9a0bdc59d7e0391ac Mon Sep 17 00:00:00 2001 From: Roger Light Date: Sat, 7 Dec 2013 23:50:03 +0000 Subject: [PATCH] Handle null will payloads correctly when connecting. --- src/paho/mqtt/client.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/paho/mqtt/client.py b/src/paho/mqtt/client.py index 47b23a4..4ea4d98 100755 --- a/src/paho/mqtt/client.py +++ b/src/paho/mqtt/client.py @@ -1598,7 +1598,11 @@ class Client: connect_flags = connect_flags | 0x02 if self._will: - remaining_length = remaining_length + 2+len(self._will_topic) + 2+len(self._will_payload) + if self._will_payload is not None: + remaining_length = remaining_length + 2+len(self._will_topic) + 2+len(self._will_payload) + else: + remaining_length = remaining_length + 2+len(self._will_topic) + 2 + connect_flags = connect_flags | 0x04 | ((self._will_qos&0x03) << 3) | ((self._will_retain&0x01) << 5) if self._username: -- 2.39.5