Skip to content

Commit

Permalink
reopened pr ThreeMammals#1030
Browse files Browse the repository at this point in the history
  • Loading branch information
Hille committed May 9, 2022
1 parent 36ad6e1 commit 5fc24cb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Ocelot/WebSockets/Middleware/WebSocketsProxyMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,21 @@ private static async Task PumpWebSocket(WebSocket source, WebSocket destination,
catch (OperationCanceledException)
{
await destination.CloseOutputAsync(WebSocketCloseStatus.EndpointUnavailable, null, cancellationToken);
if (destination.State == WebSocketState.Open || destination.State == WebSocketState.CloseReceived)
{
await destination.CloseOutputAsync(WebSocketCloseStatus.EndpointUnavailable, null, cancellationToken);
}
return;
}
catch (WebSocketException e)
{
if (e.WebSocketErrorCode == WebSocketError.ConnectionClosedPrematurely)
{
await destination.CloseOutputAsync(WebSocketCloseStatus.EndpointUnavailable, null, cancellationToken);
if (destination.State == WebSocketState.Open || destination.State == WebSocketState.CloseReceived)
{
await destination.CloseOutputAsync(WebSocketCloseStatus.EndpointUnavailable, null, cancellationToken);
}
return;
}
throw;
Expand Down

0 comments on commit 5fc24cb

Please sign in to comment.