Links2004 / arduinoWebSockets

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

WebSocket.loop() freezes and Async enabled, that doesn't work SoftwareSerial #535

Closed whakru closed 4 years ago

whakru commented 4 years ago

If I use non-Async transfer. Then after some time I get a slow motion in webSocket.loop () for up to 10 seconds or more, until it stops. Now I turned on Async. The delay disappeared, but a problem appeared. Now I can’t use SoftwareSerial normally, now it is losing data. What to do?

Links2004 commented 4 years ago

do you run a ESP32 or ESP8266? I added some more yield to the non Async, that may help.

but why Async and SoftwareSerial do not work together is something I can not answer. the Async TCP hadnling happens in ESPAsyncTCP not in the WS lib itself.

whakru commented 4 years ago

ESP8266. I already reported in ESPAsyncTCP

Links2004 commented 4 years ago

ok then I will close this ticket.

petr-fiala commented 4 years ago

not directly related to this issue, but maybe my comment will help someone..

ESP32, default sync TCP, was getting ~10sec freeze on main loop, when client not properly disconnected (disconnected power supply). Heartbeat enabled, but wasn't disconnecting a client. Problem was in my heartbeat settings webSocketServer.enableHeartbeat(500, 500, 3); this way internal lastPing variable gets refreshed before timeout is detected. I had to set pingInterval higher than pongTimeout and suddenly it works like charm: webSocketServer.enableHeartbeat(800, 500, 3);

AKTanara commented 2 years ago

not directly related to this issue, but maybe my comment will help someone..

ESP32, default sync TCP, was getting ~10sec freeze on main loop, when client not properly disconnected (disconnected power supply). Heartbeat enabled, but wasn't disconnecting a client. Problem was in my heartbeat settings webSocketServer.enableHeartbeat(500, 500, 3); this way internal lastPing variable gets refreshed before timeout is detected. I had to set pingInterval higher than pongTimeout and suddenly it works like charm: webSocketServer.enableHeartbeat(800, 500, 3);

Thanks for sharing, I'm having the same setup and issue. Even with the settings you suggested, the code goes freezing if there is an attempt to send a websocket message in the short period between improper client disconnect and disconnect detection by heartbeat which with your suggested setting takes 500x3=1500ms. Am i doing anything wrong or this is the reality to be accepted as it is whit this library? Thanks in advance.