Skip to content

Commit 35cab6f

Browse files
authored
Merge pull request #130 from flavio-fernandes/username_fix
MQTT connect with an empty username should have the proper header
2 parents 4c0c770 + 9f4c8fd commit 35cab6f

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

adafruit_minimqtt/adafruit_minimqtt.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ def connect(self, clean_session=True, host=None, port=None, keep_alive=None):
483483

484484
# Set up variable header and remaining_length
485485
remaining_length = 12 + len(self.client_id.encode("utf-8"))
486-
if self._username:
486+
if self._username is not None:
487487
remaining_length += (
488488
2
489489
+ len(self._username.encode("utf-8"))
@@ -533,9 +533,7 @@ def connect(self, clean_session=True, host=None, port=None, keep_alive=None):
533533
# [MQTT-3.1.3-11]
534534
self._send_str(self._lw_topic)
535535
self._send_str(self._lw_msg)
536-
if self._username is None:
537-
self._username = None
538-
else:
536+
if self._username is not None:
539537
self._send_str(self._username)
540538
self._send_str(self._password)
541539
if self.logger is not None:

0 commit comments

Comments
 (0)