From bad167656ac0e747f643f171440aa7ec024a816e Mon Sep 17 00:00:00 2001 From: Wendell Jones Date: Wed, 29 Apr 2026 08:30:54 -0400 Subject: [PATCH] Reduce log noise for WebSocket authentication failures - downgrade to Debug level --- .../Middleware/ExceptionMiddleware.cs | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Jellyfin.Api/Middleware/ExceptionMiddleware.cs b/Jellyfin.Api/Middleware/ExceptionMiddleware.cs index 30c2b5f2..41906582 100644 --- a/Jellyfin.Api/Middleware/ExceptionMiddleware.cs +++ b/Jellyfin.Api/Middleware/ExceptionMiddleware.cs @@ -83,11 +83,22 @@ public class ExceptionMiddleware { if (isAuthenticationError) { - // Log authentication errors as warnings with user-friendly message - _logger.LogWarning( - "Access denied: Unable to process request. Authentication token missing or invalid. URL {Method} {Url}.", - context.Request.Method, - context.Request.Path); + // WebSocket authentication failures are expected when clients connect without tokens + // Log at Debug level to reduce noise, unless it's not a WebSocket endpoint + if (context.Request.Path.StartsWithSegments("/socket", StringComparison.OrdinalIgnoreCase)) + { + _logger.LogDebug( + "WebSocket connection rejected: Authentication token missing or invalid. IP: {IP}", + context.Connection.RemoteIpAddress); + } + else + { + // Log authentication errors for non-WebSocket endpoints as warnings + _logger.LogWarning( + "Access denied: Unable to process request. Authentication token missing or invalid. URL {Method} {Url}.", + context.Request.Method, + context.Request.Path); + } } else {