esp-mqtt-rgb-led icon indicating copy to clipboard operation
esp-mqtt-rgb-led copied to clipboard

MQTT packet size

Open jaffons opened this issue 4 years ago • 3 comments

Hello. I have implemented this to ESP32 with simple cp-paste from example sketches. Basically I changed: #include <ESP8266WiFi.h> to #include <WiFi.h> analog.Writes to corresponding ledc library.

JSON library is intact as it should be.

However for some reason callback() function isn't called if JSON message is too long. 6 lines/objects is fine, 7 or more isn't.

I did found that message goes nicely to thru MQTT broker and that it doesn't matter which objects are in the payload. Other than that I'm out of ideas.

jaffons avatar May 11 '20 20:05 jaffons

I haven't seen this behavior, but I also haven't tested this code on an ESP32.

Have you tried increasing the JSON buffer size by increasing the value here?: https://github.com/corbanmailloux/esp-mqtt-rgb-led/blob/master/mqtt_esp8266_light/mqtt_esp8266_light.ino#L27

corbanmailloux avatar May 12 '20 02:05 corbanmailloux

Yeah I tried to increase JSON buffer also. Even if the JSON buffer is too short this shouldn't have effect on callback(), I think.

MQTT default message size is 128 bytes which might be an issue, and you can't define it in sketch.

I'll give this a try: https://github.com/knolleary/pubsubclient/issues/110#issuecomment-460065858 e. I wasn't able to make this work tonight :(

jaffons avatar May 12 '20 07:05 jaffons

So indeed I made local change to PubSubClient.h line 29 #define MQTT_MAX_PACKET_SIZE 512

...And now it works as intented. This problems seems to be known for long.

I wonder how you've not seen this before because this is not ESPxxx relevant issue and mqtt packet is almost always >126 bytes long..

jaffons avatar May 12 '20 18:05 jaffons