Handle unexpected disconnect

This commit is contained in:
Bond-009
2019-12-27 15:42:59 +01:00
committed by Bond_009
parent 8865b3ea3d
commit bdd823d22f
2 changed files with 11 additions and 2 deletions

View File

@@ -116,7 +116,16 @@ namespace Emby.Server.Implementations.HttpServer
{
// Allocate at least 512 bytes from the PipeWriter
Memory<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)
{