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 call multi time on big message #1234

Closed
phuonglm opened this issue Sep 28, 2018 · 5 comments
Closed

MQTT call multi time on big message #1234

phuonglm opened this issue Sep 28, 2018 · 5 comments
Labels
enhancement New feature or request mqtt
Milestone

Comments

@phuonglm
Copy link
Contributor

phuonglm commented Sep 28, 2018

Follow this document of async MQTT library, big message will be split to multi small MQTT message with difference start index. The library will call our handler multi time with payload is small message.

I think the best logic here is our _onMessage handler will check the message length, total length, start index, allocate the buffer to catch the all message before dispatch it to our _mqtt_callbacks.

I don't tested with pubsub lib but since pubsub don't give me any parameter like that so I disabled that code with pubsub library.

@xoseperez xoseperez added enhancement New feature or request mqtt labels Oct 5, 2018
@xoseperez
Copy link
Owner

This would be useful for OTA updates over MQTT since the payload is managed by the Updater class and saved to flash on the fly. Any other use could be problematic.

What use cases, aside from OTA, would benefit from a payload bigger than 1460bytes but not big enough to make the device run out of memory (say 10k)?

@phuonglm
Copy link
Contributor Author

phuonglm commented Oct 5, 2018

In my case is HVAC raw ir codes. They can easily had 30-40 bytes data and mean 40*8*2*<numbers of char per raw timer> then mqtt message can reach 2000 bytes.

@xoseperez xoseperez added this to the 1.14.0 milestone Oct 7, 2018
@abmantis
Copy link
Contributor

@xoseperez I've seen some messages fail to send (the mqtt publish method returns zero) while adding some more HA discovery features, because the messages where big.

@mcspr
Copy link
Collaborator

mcspr commented Feb 18, 2019 via email

@mcspr
Copy link
Collaborator

mcspr commented Oct 3, 2021

long-time-no-see, but this seems to be already handled by the mqtt buffer size setting circa this commit
43c2c41#diff-adf1d7b355d1037ad971dd9bf6ca48bce5d8d033d2f1e77073951c5553a2997c

static char message[((MQTT_BUFFER_MAX_SIZE + 1) + 31) & -32] = {0};

and the actual message is assembled from multiple onMessage calls

sure, this does not handle binary payloads, but none of the mqtt module funcs actually work with that. that may be another issue, but imo we also want to move away from the multiple-clients paradigm and just use a single one

@mcspr mcspr closed this as completed Oct 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request mqtt
Projects
None yet
Development

No branches or pull requests

4 participants