HiveMQ with ESP32 too slow for base64-enc images of 10-15 kB


I have set up a HiveMQ broker with an ESP32 client based on the example here: HiveMQ using ESP32 and NODERED

My code is in the Arduino framework as in the example and uses C++ libraries <WiFiClientSecure.h> and <PubSubClient.h>. When I publish a short string, the communication is near-instantaneous. When I publish an image as a base64-encoded string, it takes between 1- 10 minutes to publish. I have experimented with different image sizes down to 240 x 240 and as high as 600 x 800 pixels in JPEG. The length of the corresponding base64-encoded string varies and is in 10’s of kilo Bytes.

For comparison, I set up a local Mosquitto MQTT broker in a docker container on a computer on local network and the transactions are near-instantaneous with the same set-up. I wondered if TLS encryption is slowing the transaction down and switched to non-secure transactions with <WiFIClient.h> instead of <WiFiClientSecure.h>. Still no change!

Other modifications I made include publishing at lower frequency (once every 60 sec as opposed to once every 15 sec.) This did not make any difference either.

My Github repo is here. Any suggestions? Grateful for pointers that help.


Hi sunbee,

Were you ever able to resolve this issue?

Is there any indication (warnings, errors etc) in any logging during your process that might be useful?

Thank you for your interest in HiveMQ.

Seth - HiveMQ Support