Open mikycol opened 2 years ago
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
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.
I have this exact issue, seems to always send 88 characters for me before truncating my message. Seems like a pretty big issue.
Exactly same issue, I am facing. Now moving back to move to pubsub client lib again.
Increasing MAXBUFFERSIZE also "fixed" it for me. Should be configurable or larger in the first place, maybe depending on platform.
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?