LiveService if out of ressources close websocket
This commit is contained in:
parent
0f80a25937
commit
a758d894f6
@ -59,25 +59,29 @@ void WebApiWsLiveClass::loop()
|
||||
|
||||
// Update on every inverter change or at least after 10 seconds
|
||||
if (millis() - _lastWsPublish > (10 * 1000) || (maxTimeStamp != _newestInverterTimestamp)) {
|
||||
try {
|
||||
DynamicJsonDocument root(40960);
|
||||
JsonVariant var = root;
|
||||
generateJsonResponse(var);
|
||||
|
||||
DynamicJsonDocument root(40960);
|
||||
JsonVariant var = root;
|
||||
generateJsonResponse(var);
|
||||
String buffer;
|
||||
if (buffer) {
|
||||
serializeJson(root, buffer);
|
||||
|
||||
String buffer;
|
||||
if (buffer) {
|
||||
serializeJson(root, buffer);
|
||||
if (Configuration.get().Security_AllowReadonly) {
|
||||
_ws.setAuthentication("", "");
|
||||
} else {
|
||||
_ws.setAuthentication(AUTH_USERNAME, Configuration.get().Security_Password);
|
||||
}
|
||||
|
||||
if (Configuration.get().Security_AllowReadonly) {
|
||||
_ws.setAuthentication("", "");
|
||||
} else {
|
||||
_ws.setAuthentication(AUTH_USERNAME, Configuration.get().Security_Password);
|
||||
_ws.textAll(buffer);
|
||||
}
|
||||
|
||||
_ws.textAll(buffer);
|
||||
_lastWsPublish = millis();
|
||||
}
|
||||
catch (std::bad_alloc& bad_alloc) {
|
||||
MessageOutput.printf("Call to /api/livedata/status temporarely out of resources. Reason: \"%s\".", bad_alloc.what());
|
||||
}
|
||||
|
||||
_lastWsPublish = millis();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -55,25 +55,29 @@ void WebApiWsVedirectLiveClass::loop()
|
||||
|
||||
// Update on ve.direct change or at least after 10 seconds
|
||||
if (millis() - _lastWsPublish > (10 * 1000) || (maxTimeStamp != _newestVedirectTimestamp)) {
|
||||
try {
|
||||
DynamicJsonDocument root(1024);
|
||||
JsonVariant var = root;
|
||||
generateJsonResponse(var);
|
||||
|
||||
DynamicJsonDocument root(1024);
|
||||
JsonVariant var = root;
|
||||
generateJsonResponse(var);
|
||||
String buffer;
|
||||
if (buffer) {
|
||||
serializeJson(root, buffer);
|
||||
|
||||
if (Configuration.get().Security_AllowReadonly) {
|
||||
_ws.setAuthentication("", "");
|
||||
} else {
|
||||
_ws.setAuthentication(AUTH_USERNAME, Configuration.get().Security_Password);
|
||||
}
|
||||
|
||||
String buffer;
|
||||
if (buffer) {
|
||||
serializeJson(root, buffer);
|
||||
|
||||
if (Configuration.get().Security_AllowReadonly) {
|
||||
_ws.setAuthentication("", "");
|
||||
} else {
|
||||
_ws.setAuthentication(AUTH_USERNAME, Configuration.get().Security_Password);
|
||||
}
|
||||
_ws.textAll(buffer);
|
||||
}
|
||||
|
||||
_ws.textAll(buffer);
|
||||
_lastWsPublish = millis();
|
||||
}
|
||||
catch (std::bad_alloc& bad_alloc) {
|
||||
MessageOutput.printf("Call to /api/vedirectlivedata/status temporarely out of resources. Reason: \"%s\".", bad_alloc.what());
|
||||
}
|
||||
|
||||
_lastWsPublish = millis();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user