mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-21 05:00:39 +02:00
Handle unexpected disconnect
This commit is contained in:
parent
8865b3ea3d
commit
bdd823d22f
|
@ -540,7 +540,7 @@ namespace Emby.Server.Implementations.HttpServer
|
||||||
}
|
}
|
||||||
catch (Exception ex) // Otherwise ASP.Net will ignore the exception
|
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)
|
if (!context.Response.HasStarted)
|
||||||
{
|
{
|
||||||
context.Response.StatusCode = 500;
|
context.Response.StatusCode = 500;
|
||||||
|
|
|
@ -116,7 +116,16 @@ namespace Emby.Server.Implementations.HttpServer
|
||||||
{
|
{
|
||||||
// Allocate at least 512 bytes from the PipeWriter
|
// Allocate at least 512 bytes from the PipeWriter
|
||||||
Memory<byte> memory = writer.GetMemory(512);
|
Memory<byte> memory = writer.GetMemory(512);
|
||||||
|
try
|
||||||
|
{
|
||||||
receiveresult = await _socket.ReceiveAsync(memory, cancellationToken);
|
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;
|
int bytesRead = receiveresult.Count;
|
||||||
if (bytesRead == 0)
|
if (bytesRead == 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue