Closed fpagliughi closed 2 years ago
This will create and send a message that get mis-read:
#!/usr/bin/env python3
import gzip
import time
import paho.mqtt.publish as publish
import paho.mqtt.client as mqtt
from paho.mqtt.packettypes import PacketTypes
payload = gzip.compress(b"[]")
cli = mqtt.Client(protocol=mqtt.MQTTv5)
cli.connect("localhost", 1883, 60)
props = mqtt.Properties(PacketTypes.PUBLISH)
props.ContentType = "application/json"
props.ResponseTopic = "replies/MqttStubClient/259288/0ed0eaa8-14f8-11ed-9ae3-256dff621944"
props.CorrelationData = b"0"
props.UserProperty = ("timestamp", str(time.time()))
props.UserProperty = ("content-encoding", "gzip")
cli.publish("test", payload, 1, False, props)
cli.loop(1.0)
cli.disconnect()
Oops... looks like I had an older version of the package hidden in my path. Seems this was already fixed in the latest release. Never mind.
Hey! I'm sending RPC requests with a bunch of v5 properties. A request looks like this:
The payload is the gzip'ed form of an empty JSON array: '[]', which encodes as "\x1F\x8b..." Both Wireshark and
mosquitto_sub
confirm the proper payload. (Ignore for the moment that the "compressed" payload is 10x the size of the original!)On receipt with the Python client, it's reporting a payload of length 23 (instead of 22) as:
There appears to be an additional byte at the beginning of the payload. It's a 0x70, which is "p" - the last letter in the last user property just before the payload starts in the PUBLISH packet (i.e. the "p" in "gzip").
It does, however, appear to properly decode the properties, reporting them as:
I'm working on an x86_64, Linux Mint 20 (Ubuntu 20.04), with released Python client 1.6.1 using Python 3.8