Browse Source

Fix WebSocket disconnecting when exception is thrown during processing (#11395)

Niels van Velzen 1 year ago
parent
commit
43569082f9
1 changed files with 14 additions and 7 deletions
  1. 14 7
      Emby.Server.Implementations/HttpServer/WebSocketConnection.cs

+ 14 - 7
Emby.Server.Implementations/HttpServer/WebSocketConnection.cs

@@ -199,13 +199,20 @@ namespace Emby.Server.Implementations.HttpServer
             }
             else
             {
-                await OnReceive(
-                    new WebSocketMessageInfo
-                    {
-                        MessageType = stub.MessageType,
-                        Data = stub.Data?.ToString(), // Data can be null
-                        Connection = this
-                    }).ConfigureAwait(false);
+                try
+                {
+                    await OnReceive(
+                        new WebSocketMessageInfo
+                        {
+                            MessageType = stub.MessageType,
+                            Data = stub.Data?.ToString(), // Data can be null
+                            Connection = this
+                        }).ConfigureAwait(false);
+                }
+                catch (Exception exception)
+                {
+                    _logger.LogWarning(exception, "Failed to process WebSocket message");
+                }
             }
         }