-
Notifications
You must be signed in to change notification settings - Fork 575
-
I am using WebSockets server on ESP8266 from this library. Classical schema, nothing overcomplicated: client is written on JavaScript, running on browser, used to control ESP8266 device. I am using WSServer.broadcastTXT() to send json messages back to clients to update their web-page. Everything working very good for days, until problem happened.
Problem: If client is gone (for example, client cell phone has lost wifi) - web socket server takes very long time, around 20 minutes (!), to disconnect missing client. I see the call of WSServer.broadcastTXT() takes more than WEBSOCKETS_TCP_TIMEOUT mS, which is clearly understandable, but how to make the disconnection to trigger faster that that? Using WSServer.enableHeartbeat() with tight timing, like WSServer.enableHeartbeat(30000, 100, 3), does not change anything, except adding extra network traffic for ping-pong messages. If client just close page in browser - client closes correctly.
Are there any solution on how to enforce web socket server to disconnect missing client much earlier than 20 minutes? What is the logic of disconnection of client(s) on server side?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments
-
First step is to enable debug logging and look at the output.
all client lost detection comes from the fact the the TCP stack does not get a ACK for the send data (e.g. the ping).
a tcpdump is needed if the debug log does not shows anything, but one step at a time.
Beta Was this translation helpful? Give feedback.
All reactions
-
Are there any solution on how to enforce web socket server to disconnect missing client much earlier than 20 minutes?
Have a look at issue #922 I've made some changes to the HeartBeat code. That should solve it.
Beta Was this translation helpful? Give feedback.