Open Protoneer opened 5 years ago
My feeling is something like disconnecting client on timeout and setting a reduced timeout would solve the issue.... Not sure where the 10 second timeout is being configured.
Interesting....
As soon as I power up the laptop again the WS client gets disconnected.
you can play with the timeout here: https://github.com/Links2004/arduinoWebSockets/blob/master/src/WebSockets.h#L82 but the timeout normally is 2 sec not 10 sec.
pardon me for posting in such an old thread but I'm experiencing this exact same issue. the websocket broadcasts seem to get a bit hung up if I connect from my laptop and close the lid and absolutely happens if I connect from my iPad and it goes to sleep. the websocket clients definitely don't disconnect and it hangs up the websocket server broadcasts from my ESP32 websocket server.
when the laptop lid is closed or the iPad goes to sleep, my ESP32 program and my getConnectedClients() function still shows those clients as "connected" but the websockets broadcasts are very sporadic or don't happen at all. if I wake up the iPad or open the laptop lid again, then the broadcasts return to normal for all clients.
has anyone figured out a way to code the websocket event loop on the ESP32 so that sleeping clients don't cause the broadcasts to be hung up for all the other clients?
the code I'm using is very similar to the sample code in the Arduino IDE, which doesn't seem to handle the sleeping clients at all.
First off... Great work on this project!!!
Senario:
Reproducing:
Outcome:
[WS][0][sendFrame] sending Frame Done (3985us). [WS][0][sendFrame] ------- send message frame ------- [WS][0][sendFrame] fin: 1 opCode: 1 mask: 0 length: 11 headerToPayload: 0 [WS][0][sendFrame] text: 0,0,0,0,0,0 [WS][0][sendFrame] pack to one TCP package... [write] n: 13 t: 136799
[WS][0][sendFrame] sending Frame Done (3473us). [WS][0][sendFrame] ------- send message frame ------- [WS][0][sendFrame] fin: 1 opCode: 1 mask: 0 length: 11 headerToPayload: 0 [WS][0][sendFrame] text: 0,0,0,0,0,0 [WS][0][sendFrame] pack to one TCP package... [write] n: 13 t: 141299 [write] write TIMEOUT! 10002
[WS][0][sendFrame] sending Frame Done (10002419us). [WS][0][sendFrame] ------- send message frame ------- [WS][0][sendFrame] fin: 1 opCode: 1 mask: 0 length: 11 headerToPayload: 0 [WS][0][sendFrame] text: 0,0,0,0,0,0 [WS][0][sendFrame] pack to one TCP package... [write] n: 13 t: 151316 [write] write TIMEOUT! 10002
[WS][0][sendFrame] sending Frame Done (10002809us). [WS][0][sendFrame] ------- send message frame ------- [WS][0][sendFrame] fin: 1 opCode: 1 mask: 0 length: 11 headerToPayload: 0 [WS][0][sendFrame] text: 0,0,0,0,0,0 [WS][0][sendFrame] pack to one TCP package... [write] n: 13 t: 161333 [write] write TIMEOUT! 10002