From 8e68eb9a20638e0cb19b75e4eb4c58db50523f0a Mon Sep 17 00:00:00 2001 From: rjshrjndrn Date: Thu, 20 Mar 2025 12:33:51 +0100 Subject: [PATCH] feat(assist): enhance WebSocket session persistence Add session extraction from peerId parameter for better WebSocket connection stability. This improves assist session routing by: - Extracting sessionID from peerId parameter using regex - Setting upstream hash-by to use the extracted session ID - Adding debug headers to monitor session routing TODO: Convert this to map Signed-off-by: rjshrjndrn --- .../openreplay/charts/assist/templates/ingress.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/helmcharts/openreplay/charts/assist/templates/ingress.yaml b/scripts/helmcharts/openreplay/charts/assist/templates/ingress.yaml index 60bdcbe38..e553d8d70 100644 --- a/scripts/helmcharts/openreplay/charts/assist/templates/ingress.yaml +++ b/scripts/helmcharts/openreplay/charts/assist/templates/ingress.yaml @@ -10,7 +10,15 @@ metadata: {{- include "assist.labels" . | nindent 4 }} annotations: nginx.ingress.kubernetes.io/rewrite-target: /$1 - nginx.ingress.kubernetes.io/upstream-hash-by: $http_x_forwarded_for + nginx.ingress.kubernetes.io/configuration-snippet: | + # Extract sessionID from peerId using regex + if ($arg_peerId ~ ".*-(?[^-]+)-.*") { + set $session_id $extracted_sid; + } + add_header X-Debug-Session-ID $session_id; + add_header X-Debug-Session-Type "wss"; + nginx.ingress.kubernetes.io/upstream-hash-by: $session_id + {{- with .Values.ingress.annotations }} {{- toYaml . | nindent 4 }} {{- end }}