The Free Software Media System - Server Backend & API
Handle unexpected disconnect
Bond-009bdd823d22ff4
diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.csindex 3cdb0ecaeb..05dbad624b 100644--- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs+++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs@@ -540,7 +540,7 @@ namespace Emby.Server.Implementations.HttpServer}catch (Exception ex) // Otherwise ASP.Net will ignore the exception{- _logger.LogError(ex, "WS {IP} WebSocketRequestHandler error");+ _logger.LogError(ex, "WS {IP} WebSocketRequestHandler error", context.Connection.RemoteIpAddress);if (!context.Response.HasStarted){context.Response.StatusCode = 500;diff --git a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs b/Emby.Server.Implementations/HttpServer/WebSocketConnection.csindex 0afd0ecce1..7c0d82d899 100644--- a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs+++ b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs@@ -116,7 +116,16 @@ namespace Emby.Server.Implementations.HttpServer{// Allocate at least 512 bytes from the PipeWriterMemory<byte> memory = writer.GetMemory(512);- receiveresult = await _socket.ReceiveAsync(memory, cancellationToken);+ try+ {+ receiveresult = await _socket.ReceiveAsync(memory, cancellationToken);+ }+ catch (WebSocketException ex)+ {+ _logger.LogWarning("WS {IP} error receiving data: {Message}", RemoteEndPoint, ex.Message);+ break;+ }+int bytesRead = receiveresult.Count;if (bytesRead == 0){