Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paho 2.0.0 mqtt Client can not publish bytearray payload #833

Closed
marko92milinkovic opened this issue Apr 12, 2024 · 0 comments · Fixed by #839
Closed

Paho 2.0.0 mqtt Client can not publish bytearray payload #833

marko92milinkovic opened this issue Apr 12, 2024 · 0 comments · Fixed by #839
Labels
Status: Available No one has claimed responsibility for resolving this issue.
Milestone

Comments

@marko92milinkovic
Copy link

marko92milinkovic commented Apr 12, 2024

Bug Description

Paho 2.0.0 mqtt Client can not publish bytearray payload

Reproduction

Calling paho.mqtt.client.Client.publish with payload as bytearray with qos = 1.
The publish method internally calls _encode_payload:

....
   if not isinstance(payload, (bytes, bytearray)):
       raise TypeError(
           "payload must be a string, bytearray, int, float or None."
       )

   return payload

Then it calls _send_publish and the code blows up inside it:
if payload and not isinstance(payload, bytes): raise TypeError('payload must be bytes if set')

Environment

  • Python version: 3.10
  • Library version: 2.0.0
  • Operating system (including version): MacOS 13.6.6
  • MQTT server (name, version, configuration, hosting details): mosquitto 2.0.11

Logs

client.publish(message.topic, message.payload, 1)
File "/usr/local/lib/python3.10/site-packages/paho/mqtt/client.py", line 1798, in publish
rc = self._send_publish(message.mid, topic_bytes, message.payload, message.qos, message.retain,
File "/usr/local/lib/python3.10/site-packages/paho/mqtt/client.py", line 3377, in _send_publish
raise TypeError('payload must be bytes if set')

@github-actions github-actions bot added the Status: Available No one has claimed responsibility for resolving this issue. label Apr 12, 2024
@PierreF PierreF added this to the 2.1.0 milestone Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Available No one has claimed responsibility for resolving this issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants