...
 
Commits (4)
    https://gitcode.net/awesome-mirrors/eclipse/paho.mqtt.python/-/commit/bc524e4d70fa1e4aa04f1801d9454413b754aac0 Fix handling of MQTT v5.0 PUBREL messages with remaining length != 2 2023-01-20T22:29:44+00:00 Roger Light roger@atchoo.org Closes #696. Thanks to Masanori ITOH. https://gitcode.net/awesome-mirrors/eclipse/paho.mqtt.python/-/commit/d02976156e664e99e991797d9e4ae31829d5a2e7 Raise error on `subscribe()` when `topic` is an empty list. 2023-01-20T22:46:32+00:00 Roger Light roger@atchoo.org Closes #690. Thanks to peromvikgoodtech. https://gitcode.net/awesome-mirrors/eclipse/paho.mqtt.python/-/commit/03fcf8d97ee2ff5dad66c4b7741979a1d0b98316 - Raise error on `publish.multiple()` when `msgs` is an empty list. 2023-01-20T23:01:14+00:00 Roger Light roger@atchoo.org Closes #684. Thanks to Jinyu Liu. https://gitcode.net/awesome-mirrors/eclipse/paho.mqtt.python/-/commit/7182c3fc373019a1eebc9c70f49c9afb7b0657c1 Don't add port to Host: header for websockets connections. 2023-01-20T23:36:29+00:00 Roger Light roger@atchoo.org Closes #666. Thanks to hulb and Oliver Rahner.
v1.6.2 - 2021-xx-xx
===================
- Fix handling of MQTT v5.0 PUBREL messages with remaining length not equal to
2. Closes #696.
- Raise error on `subscribe()` when `topic` is an empty list. Closes #690.
- Raise error on `publish.multiple()` when `msgs` is an empty list. Closes #684.
- Don't add port to Host: header for websockets connections. Closes #666.
v1.6.1 - 2021-10-21
===================
......
......@@ -48,7 +48,7 @@ mqttc.on_publish = on_publish
mqttc.on_subscribe = on_subscribe
# Uncomment to enable debug messages
mqttc.on_log = on_log
mqttc.connect("test.mosquitto.org", 8080, 60)
mqttc.connect("test.mosquitto.org", 443, 60)
mqttc.subscribe("$SYS/broker/version", 0)
mqttc.loop_forever()
......@@ -54,6 +54,6 @@ mqttc.on_subscribe = on_subscribe
# Uncomment to enable debug messages
# mqttc.on_log = on_log
mqttc.connect("mqtt.eclipseprojects.io", 1883, 60)
mqttc.subscribe("$SYS/#", 0)
mqttc.subscribe([])
mqttc.loop_forever()
......@@ -1467,6 +1467,8 @@ class Client(object):
raise ValueError('Invalid topic.')
topic_qos_list = [(topic.encode('utf-8'), qos)]
elif isinstance(topic, list):
if len(topic) == 0:
raise ValueError('Empty topic list')
topic_qos_list = []
if self._protocol == MQTTv5:
for t, o in topic:
......@@ -3345,7 +3347,15 @@ class Client(object):
elif self._in_packet['remaining_length'] != 2:
return MQTT_ERR_PROTOCOL
mid, = struct.unpack("!H", self._in_packet['packet'])
mid, = struct.unpack("!H", self._in_packet['packet'][:2])
if self._protocol == MQTTv5:
if self._in_packet['remaining_length'] > 2:
reasonCode = ReasonCodes(PUBREL >> 4)
reasonCode.unpack(self._in_packet['packet'][2:])
if self._in_packet['remaining_length'] > 3:
properties = Properties(PUBREL >> 4)
props, props_len = properties.unpack(
self._in_packet['packet'][3:])
self._easy_log(MQTT_LOG_DEBUG, "Received PUBREL (Mid: %d)", mid)
with self._in_message_mutex:
......@@ -3723,7 +3733,7 @@ class WebsocketWrapper(object):
sec_websocket_key = base64.b64encode(sec_websocket_key)
websocket_headers = {
"Host": "{self._host:s}:{self._port:d}".format(self=self),
"Host": "{self._host:s}".format(self=self),
"Upgrade": "websocket",
"Connection": "Upgrade",
"Origin": "https://{self._host:s}:{self._port:d}".format(self=self),
......
......@@ -135,6 +135,8 @@ def multiple(msgs, hostname="localhost", port=1883, client_id="", keepalive=60,
if not isinstance(msgs, Iterable):
raise TypeError('msgs must be an iterable')
if len(msgs) == 0:
raise ValueError('msgs is empty')
client = paho.Client(client_id=client_id, userdata=collections.deque(msgs),
......