ESP8266MQTTMesh icon indicating copy to clipboard operation
ESP8266MQTTMesh copied to clipboard

Doubt regarding reducing socket timeout

Open jassi00713 opened this issue 6 years ago • 3 comments

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

jassi00713 avatar Mar 30 '18 18:03 jassi00713

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.

PhracturedBlue avatar Mar 30 '18 20:03 PhracturedBlue

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.

jassi00713 avatar Mar 31 '18 04:03 jassi00713

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.

PhracturedBlue avatar Apr 01 '18 13:04 PhracturedBlue