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

Message length limit when publishing #200

Open
mikycol opened this issue Aug 17, 2021 · 5 comments
Open

Message length limit when publishing #200

mikycol opened this issue Aug 17, 2021 · 5 comments

Comments

@mikycol
Copy link

mikycol commented Aug 17, 2021

Through the sketch in the library I'm trying to publish the following message {"unique_id": "TAVERNETTA-temperature","device_class": "temperature", "name": "TAVERNETTA Temperature", "state_topic": "homeassistant/sensor/TAVERNETTA/state", "unit_of_measurement": "°C", "value_template": "{{ value_json.temperature}}"}, but the message that arrives is truncated with a length of 147 characters.

I'm pretty sure I made some mistakes, but I can't figure it out.

Any suggestions?

@gak
Copy link

gak commented Sep 25, 2021

I'm having a similar issue, but it's only sending 89 chars. It's on an ESP32-S2. Using 2.4.2 installed via the Arduino IDE.

If I set QoS to 1 or 2, it fails to send at all.

char encoded[2000];

// Some JSON generation here.
// I've tried this with just creating a long string by hand, e.g.:
// char *encoded = "very long string";
// with exactly the same truncation.

Serial.println(motion_config_topic.c_str());
Serial.println(encoded);
Serial.println(strlen(encoded));

if (!messages->publish(motion_config_topic.c_str(), encoded, 0)) {
    Serial.println("Failed to send motion config.");
}

The related output:

16:50:01.893 -> homeassistant/binary_sensor/esp32s2-0edc60-motion/config
16:50:01.893 -> {"name":"esp32s2-0edc60","unique_id":"esp32s2-0edc60-motion","device_class":"motion","state_topic":"homeassistant/binary_sensor/esp32s2-0edc60-motion/state"}
16:50:01.893 -> 157

I've successfully sent a longer message using using another MQTT client. I've received the truncation using two separate clients (home assistant and a rust app). Here is the truncated message for completeness:

{"name":"esp32s2-0edc60","unique_id":"esp32s2-0edc60-motion","device_class":"motion","sta

@gak
Copy link

gak commented Sep 25, 2021

Increasing MAXBUFFERSIZE does the trick. Not sure how stable this solution is but it works for me so far.

Edit: Still had issues. Went with https://github.com/plapointe6/EspMQTTClient which allows changing the max packet size and worked first go.

@SaberShip
Copy link

I have this exact issue, seems to always send 88 characters for me before truncating my message. Seems like a pretty big issue.

@MEHUL95
Copy link

MEHUL95 commented Dec 29, 2022

Exactly same issue, I am facing. Now moving back to move to pubsub client lib again.

@jsphuebner
Copy link

Increasing MAXBUFFERSIZE also "fixed" it for me. Should be configurable or larger in the first place, maybe depending on platform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants