Links2004 / arduinoWebSockets

arduinoWebSockets
GNU Lesser General Public License v2.1
1.87k stars 555 forks source link

WebSocket Port Forwarding Issue #597

Open ing-IP opened 3 years ago

ing-IP commented 3 years ago

Port forwading works fine most of the time but there is situation when everything starts to stuck. ESP (server) is connected via home wifi, and I am using mobile phone to connect on the ESP remotely (either using same wifi or mobile data). When ESP web page is active on my phone and just switching between networks (wifi <-> mobile data) ESP starts to stuck (Serial printing is very very slow and you can not see web socket data on web page just HTTP). If web page is closed before switching between networks everything is ok. Maybe someting with client disconnection cause issue?

Links2004 commented 3 years ago

have you tried to enable the Heartbeat function of the server? the ESP TCP stack is quit sensitive to clients not closing sockets correctly. the Heartbeat can help to detect dead connections and force a close on the server side.

https://github.com/Links2004/arduinoWebSockets/blob/ebb87cdc8aa1f4024afeb9d65521c338abbf05e5/src/WebSocketsServer.h#L90