ESP8266MQTTMesh
ESP8266MQTTMesh copied to clipboard
Doubt regarding reducing socket timeout
When i suddenly take out or switch off the mesh Gateway, the nodes still keep showing a valid connection for sometime.
How to reduce that time? Keep Alive time or something like that needs to be reduced
Do you mean that the nodes don't detect that the gateway node is no longer present, and so don't try to find an alternate path?
This appears to be an issue with the ESP8266 core code, and I'm not sure it is fixable. As per this message from a year ago, it doesn't seem to be configurable: https://github.com/esp8266/Arduino/issues/3279#issuecomment-303388329
A workaround may be to send a 'ping' every so often and reset if it isn't returned. If the 2.4.0 core didn't address this, that may be the only option.
hmm It seems that changing the keep alive time is not allowed in the SDK. Well, we will have to settle with sending the pings which is not a bad option.
Actually, I am not sure why this isn't already working. There is an onTimeout callback which should be triggered within 5 seconds if there is no ACK from the server after sending a message. Yet I don't see the expected timeout getting called in this case. We may be able to use the lack of an ACK to trigger the disconnect though. When things are working, every packet gets ACKed quickly. When things stop working, we don't see the ACKs come in.