umqtt.simple/umqtt/simple.py MQTTClient.publish() breaks on unicode
@Josverl is already working on this.
Since Mar 9, 2026.
Assessment
This issue has not been assessed yet.
Description
I've been looking over this for a couple of weeks, and I'm struggling to find the underlying issue.
On a live MQTT session (I'm running from a RP2040 to a Mosquitto server), a mq.publish with a unicode character will break the session, eventually resulting in a Errno 104 / ECONNRESET (presumably when the input buffer is full).
The more "obvious" way to observe it is to do a mosquitto_sub on the topic, and the publish method stops transmitting data.
To observe:
mosquitto_sub -h yourserver -t homeassistant/sensor/bedroom/# -v
From a micropython:
mq.publish('homeassistant/sensor/bedroom/mytest', 'F') # works fine
mq.publish('homeassistant/sensor/bedroom/mytest' '°F') # \u0080 followed by F, appears to work
mq.publish('homeassistant/sensor/bedroom/mytest', 'F') # no data is received
subsequent/enough further publish() calls will result in the ECONNRESET
Testing against mosquitto_pub with the same topic and unicode message indicate it all works.
Somehow I think the length calculation is thrown off by the string-vs-bytes-vs-unicode thing, but haven't been able to nail it down yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 1.1k
- Avg merge
- 7d 4h
- Merged PRs (30d)
- 4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from micropython/micropython-lib
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
micropython/micropython-lib#1074 ·
-
needs-info
Difficulty 1/5 Under an hour Newbie friendliness 72/100
micropython/micropython-lib#943 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
micropython/micropython-lib#931 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 62/100
micropython/micropython-lib#795 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
micropython/micropython-lib#762 ·
All issues in micropython/micropython-lib
Similar issues
-
bug confirmed issue
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
open-webui/open-webui#30750 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 90/100