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

MQTT packet size #60

Open
jaffons opened this issue May 11, 2020 · 3 comments
Open

MQTT packet size #60

jaffons opened this issue May 11, 2020 · 3 comments
Labels

Comments

@jaffons
Copy link

jaffons commented May 11, 2020

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.

@corbanmailloux
Copy link
Owner

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

@jaffons
Copy link
Author

jaffons commented May 12, 2020

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:
knolleary/pubsubclient#110 (comment)
e. I wasn't able to make this work tonight :(

@jaffons
Copy link
Author

jaffons commented May 12, 2020

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 jaffons changed the title JSON message length MQTT packet length May 14, 2020
@jaffons jaffons changed the title MQTT packet length MQTT packet size May 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants