-
-
Notifications
You must be signed in to change notification settings - Fork 345
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 high delay on publish #1760
Comments
Ok, in LWIP the timers are triggered on a period of time. In the ESP8266 LWIP version they are defined like this:
You can eventually recompile LWIP with TCP_TMR_INTERVAL value that is lower than 125. Thus resulting in frequent checks. But beware
Concerning the issue with MqttClient. We can eventually add a directive, disabled by default, that tries to poll right after queueing a publish message, similar to what you have in your work-around code. But that is a hack :( and that is why I am so hesitant to add it. Anyone with experience in LWIP having a better idea? |
Or - enable it by default but force-poll only when the message size is lower than 300 bytes. Which I guess is also the case for you @verybadsoldier, right? |
Hm, I understand it in a way that the delay should be a maximum of 125 ms in the worst case, right? Any idea why I saw delays up to 1000 ms?
In general I think it would make sense to be able to trigger the polling when we know there is data queued that should be sent immediately. No need to wait for polling in that case. Yes, in my case the MQTT messages are below 300 bytes. |
One further note: |
I am experiencing a delay between publishing an MQTT message and the actual write to the TCP stack (similar to this issue: #547). The delays is can up to ~1 s which is pretty much a killer in out RGBWW LED firmware which can synchronize multiple LED controllers using MQTT.
It is reproducible with the sample
MqttClient_Hello
. This is the output of the run:Note the gap between the message
Let's publish message now
and theTCP written
message. I added some brain-calculated time-diffs in braces.Quoting myself from the other ticket:
Well, some time went by and I managed to at least understand a bit of what's going on. Probably nothing new to you but sending happens in MqttClient::onReadyToSendData. But that function is only called periodically so buffered data which is supposed to be sent might get delayed.
Is there anything I can do about it to make MQTT messages getting sent instantly?
I came up with a dirty hack by calling MqttClient::onReadyToSendData manually after publish. But yeah, it's dirty and I am unsure about side effects:
verybadsoldier/Sming@61c34e1
With that patch applied I get nearly instant diffs:
The text was updated successfully, but these errors were encountered: