From cf5472f4c98eaa91813cbc56732b3b40227a0a92 Mon Sep 17 00:00:00 2001 From: mi3z Date: Mon, 23 Oct 2017 16:04:26 +0200 Subject: [PATCH 1/2] fixed #78 fixed Error in zero length client id when using 3.1.1 #78 --- hbmqtt/mqtt/connect.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hbmqtt/mqtt/connect.py b/hbmqtt/mqtt/connect.py index 3359482..6b16e26 100644 --- a/hbmqtt/mqtt/connect.py +++ b/hbmqtt/mqtt/connect.py @@ -7,6 +7,7 @@ from hbmqtt.codecs import bytes_to_int, decode_data_with_length, decode_string, from hbmqtt.mqtt.packet import MQTTPacket, MQTTFixedHeader, CONNECT, MQTTVariableHeader, MQTTPayload from hbmqtt.errors import HBMQTTException, NoDataException from hbmqtt.adapters import ReaderAdapter +from hbmqtt.utils import gen_client_id class ConnectVariableHeader(MQTTVariableHeader): @@ -161,6 +162,9 @@ class ConnectPayload(MQTTPayload): except NoDataException: payload.client_id = None + if (payload.client_id is None or payload.client_id == ""): + payload.client_id=gen_client_id(); + # Read will topic, username and password if variable_header.will_flag: try: From 3fc4bb7a9e9a160ddb8b6833231cedf14b8d72cc Mon Sep 17 00:00:00 2001 From: mi3z Date: Thu, 9 Nov 2017 17:32:07 +0100 Subject: [PATCH 2/2] fixed port for test_connect_ws fixed port used for ws test from 8081 (which is wss) to 8080. --- tests/test_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_client.py b/tests/test_client.py index bb3456b..978f8a0 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -103,7 +103,7 @@ class MQTTClientTest(unittest.TestCase): broker = Broker(broker_config, plugin_namespace="hbmqtt.test.plugins") yield from broker.start() client = MQTTClient() - yield from client.connect('ws://localhost:8081/') + yield from client.connect('ws://localhost:8080/') self.assertIsNotNone(client.session) yield from client.disconnect() yield from broker.shutdown()