From e852346b9477952048eb4cb8b37cecdbc88fb1a7 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Wed, 14 Jan 2026 16:22:05 +0100 Subject: [PATCH] Update mood handling in FalukantService and enhance Socket.io configuration in store - Modified mood assignment in FalukantService to conditionally wrap mood data in an object based on moodId presence, improving data structure consistency. - Refactored Socket.io initialization in the store to dynamically set the secure option based on the URL scheme, enhancing connection security in production environments. --- backend/services/falukantService.js | 2 +- check-websocket-services.sh | 53 +++++++++++++++++++++++++++++ frontend/src/store/index.js | 13 +++++-- 3 files changed, 64 insertions(+), 4 deletions(-) create mode 100755 check-websocket-services.sh diff --git a/backend/services/falukantService.js b/backend/services/falukantService.js index cd90b6a..10ccebf 100644 --- a/backend/services/falukantService.js +++ b/backend/services/falukantService.js @@ -3035,7 +3035,7 @@ class FalukantService extends BaseService { gender: char2.gender, firstName: firstNameMap.get(char2.firstName) || 'Unknown', nobleTitle: titleMap.get(char2.titleOfNobility) || '', - mood: moodMap.get(char2.moodId) || null, + mood: char2.moodId ? { tr: moodMap.get(char2.moodId) || null } : null, moodId: char2.moodId, traits: traitsMap.get(char2.id) || [] } : null, diff --git a/check-websocket-services.sh b/check-websocket-services.sh new file mode 100755 index 0000000..1554b81 --- /dev/null +++ b/check-websocket-services.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +echo "=== WebSocket-Services Diagnose ===" +echo "" + +echo "1. Prüfe Backend-Service-Status:" +sudo systemctl status yourpart-backend --no-pager -l | head -20 +echo "" + +echo "2. Prüfe Daemon-Service-Status:" +sudo systemctl status yourpart-daemon --no-pager -l | head -20 +echo "" + +echo "3. Prüfe Backend-Logs (letzte 30 Zeilen):" +sudo journalctl -u yourpart-backend -n 30 --no-pager | grep -E "(Socket|HTTPS|TLS|Port|4443|2020)" || echo "Keine relevanten Logs gefunden" +echo "" + +echo "4. Prüfe Daemon-Logs (letzte 30 Zeilen):" +sudo journalctl -u yourpart-daemon -n 30 --no-pager | grep -E "(Daemon|WSS|TLS|Port|4551|connection)" || echo "Keine relevanten Logs gefunden" +echo "" + +echo "5. Prüfe, welche Ports lauschen:" +echo " Port 2020 (API):" +sudo netstat -tlnp 2>/dev/null | grep ":2020 " || echo " ❌ Port 2020 lauscht nicht" +echo " Port 4443 (Socket.io):" +sudo netstat -tlnp 2>/dev/null | grep ":4443 " || echo " ❌ Port 4443 lauscht nicht" +echo " Port 4551 (Daemon):" +sudo netstat -tlnp 2>/dev/null | grep ":4551 " || echo " ❌ Port 4551 lauscht nicht" +echo "" + +echo "6. Prüfe Firewall-Regeln:" +sudo ufw status | grep -E "(4443|4551)" || echo " Keine Firewall-Regeln für diese Ports gefunden" +echo "" + +echo "7. Prüfe Backend-Umgebungsvariablen:" +sudo systemctl show yourpart-backend --property=Environment --no-pager | grep -E "(SOCKET_IO|TLS)" || echo " Keine Socket.io TLS-Variablen gefunden" +echo "" + +echo "8. Prüfe Daemon-Umgebungsvariablen:" +sudo systemctl show yourpart-daemon --property=Environment --no-pager | grep -E "(DAEMON|TLS)" || echo " Keine Daemon TLS-Variablen gefunden" +echo "" + +echo "9. Teste TLS-Zertifikate:" +if [ -f "/etc/letsencrypt/live/www.your-part.de/privkey.pem" ]; then + echo " ✅ Privkey gefunden" +else + echo " ❌ Privkey nicht gefunden" +fi +if [ -f "/etc/letsencrypt/live/www.your-part.de/fullchain.pem" ]; then + echo " ✅ Fullchain gefunden" +else + echo " ❌ Fullchain nicht gefunden" +fi diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js index 9059de0..463ca9f 100644 --- a/frontend/src/store/index.js +++ b/frontend/src/store/index.js @@ -213,10 +213,17 @@ const store = createStore({ } } - const socket = io(socketIoUrl, { - secure: true, + // Socket.io-Konfiguration: In Produktion mit HTTPS verwenden wir wss:// + const socketOptions = { transports: ['websocket', 'polling'] - }); + }; + + // Wenn HTTPS verwendet wird, muss secure: true gesetzt sein + if (socketIoUrl.startsWith('https://')) { + socketOptions.secure = true; + } + + const socket = io(socketIoUrl, socketOptions); socket.on('connect', () => { state.backendRetryCount = 0; // Reset retry counter on successful connection