-
Notifications
You must be signed in to change notification settings - Fork 50
Closed
Description
Current version of adafruit_minimqtt.py uses len() method to calculate a packet's remaining length, for example:
packet_length += sum(len(topic) for topic, qos in topics) |
remaining_length = 2 + len(msg) + len(topic) |
As shown above, strings are measured instead of UTF-8 bytes. When a topic only contains English characters, numbers and punctuation marks, the calculation result is correct; However, when it contains some utf-8-3 or utf-8-4 characters (such as Chinese characters) , an incorrect calculation result of remaining length will be obtained. For example, the actual encoding length of "中文" should be 6, while the length calculated by len() is 2. As a result, such packets will be rejected by any MQTT server.
In MQTT protocol, there is no restriction on utf-8-3 or utf-8-4 characters, so I think this issue is probably a bug that needs to be fixed.
At present, in the application I developed, I rewrite the len() method to temporarily solve this problem, but I still hope that the developers of this library can make official bug fixes.
Thank you very much.
Metadata
Metadata
Assignees
Labels
No labels