Skip to content

umqtt.simple: allow no password in connect packet #302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions umqtt.simple/umqtt/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ def connect(self, clean_session=True):
sz = 10 + 2 + len(self.client_id)
msg[6] = clean_session << 1
if self.user is not None:
sz += 2 + len(self.user) + 2 + len(self.pswd)
msg[6] |= 0xC0
sz += 2 + len(self.user)
msg[6] |= 1 << 7
if self.pswd is not None:
sz += 2 + len(self.pswd)
msg[6] |= 1 << 6
if self.keepalive:
assert self.keepalive < 65536
msg[7] |= self.keepalive >> 8
Expand All @@ -92,7 +95,8 @@ def connect(self, clean_session=True):
self._send_str(self.lw_msg)
if self.user is not None:
self._send_str(self.user)
self._send_str(self.pswd)
if self.pswd is not None:
self._send_str(self.pswd)
resp = self.sock.read(4)
assert resp[0] == 0x20 and resp[1] == 0x02
if resp[3] != 0:
Expand Down