From 9f0076a056535740263f28ab79eaa68c43cf561a Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Wed, 5 Feb 2025 05:12:24 +0100 Subject: [PATCH 1/2] Remove peer MaxConnectionTime There is no need to always disconnect the Websocket connection after an hour. This just causes issues once in a while with db queries being executed at the same time and then being cancelled. --- internal/signaling/handler.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/internal/signaling/handler.go b/internal/signaling/handler.go index 2ff5291..66e1115 100644 --- a/internal/signaling/handler.go +++ b/internal/signaling/handler.go @@ -17,8 +17,6 @@ import ( "go.uber.org/zap" ) -const MaxConnectionTime = 1 * time.Hour - const LobbyCleanInterval = 30 * time.Minute const LobbyCleanThreshold = 24 * time.Hour @@ -51,9 +49,6 @@ func Handler(ctx context.Context, store stores.Store, cloudflare *cloudflare.Cre logger := logging.GetLogger(ctx) logger.Debug("upgrading connection") - ctx, cancel := context.WithTimeout(ctx, MaxConnectionTime) - defer cancel() - acceptOptions := &websocket.AcceptOptions{ InsecureSkipVerify: true, // Allow any origin/game to connect. CompressionMode: websocket.CompressionDisabled, From 20b3d39de7af72ab58fa38d58e24616cf32bdea4 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Wed, 5 Feb 2025 10:25:58 +0100 Subject: [PATCH 2/2] Fix suggestion --- internal/signaling/handler.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/signaling/handler.go b/internal/signaling/handler.go index 66e1115..6e105f8 100644 --- a/internal/signaling/handler.go +++ b/internal/signaling/handler.go @@ -49,6 +49,9 @@ func Handler(ctx context.Context, store stores.Store, cloudflare *cloudflare.Cre logger := logging.GetLogger(ctx) logger.Debug("upgrading connection") + ctx, cancel := context.WithCancel(ctx) + defer cancel() + acceptOptions := &websocket.AcceptOptions{ InsecureSkipVerify: true, // Allow any origin/game to connect. CompressionMode: websocket.CompressionDisabled,