mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-15 18:08:53 -07:00
Don't close the socket response multiple times
This commit is contained in:
parent
4a3e42e779
commit
6e07eab247
@ -129,6 +129,7 @@ namespace Jellyfin.Server.SocketSharp
|
||||
|
||||
private async Task ProcessWebSocketRequest(HttpListenerContext ctx)
|
||||
{
|
||||
int statusCode = 200;
|
||||
try
|
||||
{
|
||||
var endpoint = ctx.Request.RemoteEndPoint.ToString();
|
||||
@ -164,33 +165,23 @@ namespace Jellyfin.Server.SocketSharp
|
||||
Endpoint = endpoint
|
||||
});
|
||||
|
||||
await ReceiveWebSocketAsync(ctx, socket).ConfigureAwait(false);
|
||||
await socket.StartReceive().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogWarning("Web socket connection not allowed");
|
||||
ctx.Response.StatusCode = 401;
|
||||
ctx.Response.Close();
|
||||
statusCode = 401;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "AcceptWebSocketAsync error");
|
||||
ctx.Response.StatusCode = 500;
|
||||
ctx.Response.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ReceiveWebSocketAsync(HttpListenerContext ctx, SharpWebSocket socket)
|
||||
{
|
||||
try
|
||||
{
|
||||
await socket.StartReceive().ConfigureAwait(false);
|
||||
statusCode = 500;
|
||||
}
|
||||
finally
|
||||
{
|
||||
TryClose(ctx, 200);
|
||||
TryClose(ctx, statusCode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -201,10 +192,6 @@ namespace Jellyfin.Server.SocketSharp
|
||||
ctx.Response.StatusCode = statusCode;
|
||||
ctx.Response.Close();
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
// TODO: Investigate and properly fix.
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error closing web socket response");
|
||||
|
Loading…
Reference in New Issue
Block a user