From d5a09f359d7a6aeb8b7bb1cf733aa5cce7e0de5c Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Thu, 20 Nov 2025 17:43:23 +0100 Subject: [PATCH] Enhance logging and error handling in getConnections callback - Add detailed logging to track the flow and validity of user data during the getConnections event. - Implement exception handling to manage potential access issues with user data, improving stability and error visibility. - Ensure clear output for both successful and failed user data access attempts, aiding in debugging and monitoring. --- src/websocket_server.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/websocket_server.cpp b/src/websocket_server.cpp index a4187d5..ca4dae9 100644 --- a/src/websocket_server.cpp +++ b/src/websocket_server.cpp @@ -320,10 +320,22 @@ int WebSocketServer::wsCallback(struct lws *wsi, } } else if (event == "getConnections") { // Admin-Funktion: Liste aller aktiven Verbindungen + std::cout << "[RECEIVE] getConnections: Start" << std::endl; if (!ud) { std::cerr << "[RECEIVE] getConnections: ud ist nullptr" << std::endl; break; } + std::cout << "[RECEIVE] getConnections: ud ist gültig" << std::endl; + + // Prüfe ob ud noch gültig ist, bevor wir darauf zugreifen + try { + volatile bool test = ud->pongReceived; + (void)test; + std::cout << "[RECEIVE] getConnections: ud-Zugriff erfolgreich" << std::endl; + } catch (...) { + std::cerr << "[RECEIVE] getConnections: ud ist ungültig (Exception beim Zugriff)" << std::endl; + break; + } if (ud->userId.empty()) { std::cerr << "[RECEIVE] getConnections: User-ID nicht gesetzt" << std::endl;