mirror of
https://github.com/wled/WLED.git
synced 2025-07-16 07:16:31 +00:00
WS reconnect logic & WS memory leak protection
This commit is contained in:
parent
e9a05890a5
commit
3be4b69b44
@ -974,8 +974,14 @@ function makeWS() {
|
||||
displayRover(info, s);
|
||||
readState(json.state);
|
||||
};
|
||||
ws.onclose = function(event) {
|
||||
ws.onclose = (e)=>{
|
||||
d.getElementById('connind').style.backgroundColor = "#831";
|
||||
ws = null;
|
||||
if (lastinfo.ws > -1) setTimeout(makeWS,500); //retry WS connection
|
||||
}
|
||||
ws.onopen = (e)=>{
|
||||
ws.send("{'v':true}");
|
||||
reqsLegal = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
1580
wled00/html_ui.h
1580
wled00/html_ui.h
File diff suppressed because it is too large
Load Diff
@ -108,9 +108,12 @@ void sendDataWs(AsyncWebSocketClient * client)
|
||||
JsonObject info = doc.createNestedObject("info");
|
||||
serializeInfo(info);
|
||||
size_t len = measureJson(doc);
|
||||
buffer = ws.makeBuffer(len);
|
||||
if (!buffer) {
|
||||
size_t heap1 = ESP.getFreeHeap();
|
||||
buffer = ws.makeBuffer(len); // will not allocate correct memory sometimes
|
||||
size_t heap2 = ESP.getFreeHeap();
|
||||
if (!buffer || heap1-heap2<len) {
|
||||
releaseJSONBufferLock();
|
||||
ws.cleanupClients(0); // disconnect all clients to release memory
|
||||
return; //out of memory
|
||||
}
|
||||
serializeJson(doc, (char *)buffer->get(), len +1);
|
||||
@ -155,7 +158,11 @@ void handleWs()
|
||||
{
|
||||
if (millis() - wsLastLiveTime > WS_LIVE_INTERVAL)
|
||||
{
|
||||
#ifdef ESP8266
|
||||
ws.cleanupClients(2);
|
||||
#else
|
||||
ws.cleanupClients();
|
||||
#endif
|
||||
bool success = true;
|
||||
if (wsLiveClientId)
|
||||
success = sendLiveLedsWs(wsLiveClientId);
|
||||
|
Loading…
x
Reference in New Issue
Block a user