]> git.michaelhowe.org Git - packages/p/paho-mqtt.git/commitdiff
Fix CONNECT packet for MQTT v3.1.1.
authorRoger A. Light <roger@atchoo.org>
Mon, 12 May 2014 19:41:53 +0000 (20:41 +0100)
committerRoger A. Light <roger@atchoo.org>
Mon, 12 May 2014 19:41:53 +0000 (20:41 +0100)
ChangeLog.txt [new file with mode: 0644]
src/paho/mqtt/client.py

diff --git a/ChangeLog.txt b/ChangeLog.txt
new file mode 100644 (file)
index 0000000..380bcf1
--- /dev/null
@@ -0,0 +1,4 @@
+v0.9.1
+======
+
+- Fix CONNECT packet for MQTT v3.1.1.
index c52ac6311d63f0fe744d72acb6305cd8fee36628..49fc9502f31de9ee5f044de33f03b9eabef22b63 100755 (executable)
@@ -1684,7 +1684,13 @@ class Client(object):
         return self._packet_queue(command, packet, 0, 0)
 
     def _send_connect(self, keepalive, clean_session):
-        remaining_length = 12 + 2+len(self._client_id)
+        if self._protocol == MQTTv31:
+            protocol = PROTOCOL_NAMEv31
+            proto_ver = 3
+        else:
+            protocol = PROTOCOL_NAMEv311
+            proto_ver = 4
+        remaining_length = 2+len(protocol) + 1+1+2 + 2+len(self._client_id)
         connect_flags = 0
         if clean_session:
             connect_flags = connect_flags | 0x02
@@ -1708,12 +1714,6 @@ class Client(object):
         packet = bytearray()
         packet.extend(struct.pack("!B", command))
         self._pack_remaining_length(packet, remaining_length)
-        if self._protocol == MQTTv31:
-            protocol = PROTOCOL_NAMEv31
-            proto_ver = 3
-        else:
-            protocol = PROTOCOL_NAMEv311
-            proto_ver = 4
 
         packet.extend(struct.pack("!H"+str(len(protocol))+"sBBH", len(protocol), protocol, proto_ver, connect_flags, keepalive))