Better handling of out of memory situations in live data websocket

This commit is contained in:
Thomas Basler 2024-01-04 14:31:09 +01:00
parent ca18d2c841
commit ef9f0040e8

View File

@ -6,6 +6,7 @@
#include "Configuration.h"
#include "Datastore.h"
#include "MessageOutput.h"
#include "Utils.h"
#include "WebApi.h"
#include "defaults.h"
#include <AsyncJson.h>
@ -64,11 +65,11 @@ void WebApiWsLiveClass::loop()
try {
std::lock_guard<std::mutex> lock(_mutex);
DynamicJsonDocument root(4096 * INV_MAX_COUNT);
if (Utils::checkJsonAlloc(root, __FUNCTION__, __LINE__)) {
JsonVariant var = root;
generateJsonResponse(var);
String buffer;
if (buffer) {
serializeJson(root, buffer);
if (Configuration.get().Security.AllowReadonly) {