From 522e5b767dabd7b7f35bdbcc609255cf2e802332 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Thu, 4 Sep 2025 00:36:34 +0200 Subject: [PATCH] Fix: Daemon WebSocket mit benutzerdefiniertem Protokoll 'yourpart-protocol' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: - Daemon-Service verwendet libwebsockets mit benutzerdefiniertem Protokoll - Frontend versuchte Standard-WebSocket-Verbindung ohne Protokoll - JSON-Nachrichten fehlten user_id Feld Lösung: - WebSocket-Verbindung mit 'yourpart-protocol' Protokoll - JSON-Nachrichten mit user_id Feld korrigiert - Apache-Konfiguration für benutzerdefiniertes Protokoll angepasst Protokoll-Details: - Protokoll: 'yourpart-protocol' (libwebsockets C-Bibliothek) - Port: 4551 (Daemon-Service) - Ping/Pong: Alle 30 Sekunden - Message-Format: JSON mit user_id Feld - Events: setUserId, getWorkerStatus, production_ready, etc. Frontend-Änderungen: - new WebSocket(url, 'yourpart-protocol') - JSON mit user_id: state.user.id - Apache: ProxyPass mit upgrade=websocket für /ws/ --- frontend/src/store/index.js | 3 ++- yourpart-https.conf | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js index fdfc191..dc24c62 100644 --- a/frontend/src/store/index.js +++ b/frontend/src/store/index.js @@ -130,11 +130,12 @@ const store = createStore({ } console.log('🔌 Initializing Daemon WebSocket connection to:', import.meta.env.VITE_DAEMON_SOCKET); try { - const daemonSocket = new WebSocket(import.meta.env.VITE_DAEMON_SOCKET); + const daemonSocket = new WebSocket(import.meta.env.VITE_DAEMON_SOCKET, 'yourpart-protocol'); daemonSocket.onopen = () => { console.log('✅ Daemon WebSocket connected successfully'); const payload = JSON.stringify({ + user_id: state.user.id, event: 'setUserId', data: { userId: state.user.id } }); diff --git a/yourpart-https.conf b/yourpart-https.conf index 6b37a86..941ab28 100644 --- a/yourpart-https.conf +++ b/yourpart-https.conf @@ -37,8 +37,9 @@ RewriteCond %{HTTP:Connection} upgrade [NC] RewriteRule ^/ws/(.*)$ "ws://localhost:4551/$1" [P,L] - # Blockiere alle anderen /ws/ Requests (nur WebSocket-Upgrade erlaubt) - ProxyPass "/ws/" "!" + # WebSocket-Proxy für Daemon-Verbindungen mit benutzerdefiniertem Protokoll + ProxyPass "/ws/" "ws://localhost:4551/" upgrade=websocket + ProxyPassReverse "/ws/" "ws://localhost:4551/" ErrorLog /var/log/apache2/yourpart.error.log CustomLog /var/log/apache2/yourpart.access.log combined