aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2019-12-27 15:42:59 +0100
committerBond_009 <bond.009@outlook.com>2020-01-13 20:06:08 +0100
commitbdd823d22ff4d20e8aa2e5d8bf34e0faaad285ba (patch)
tree818b4c91376fe58bc31016d8fd623c3880910311 /Emby.Server.Implementations/HttpServer/WebSocketConnection.cs
parent8865b3ea3d0af201c37aa129016b843f0b9fe686 (diff)
Handle unexpected disconnect
Diffstat (limited to 'Emby.Server.Implementations/HttpServer/WebSocketConnection.cs')
-rw-r--r--Emby.Server.Implementations/HttpServer/WebSocketConnection.cs11
1 files changed, 10 insertions, 1 deletions
diff --git a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs
index 0afd0ecce..7c0d82d89 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 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)
{