Skip to content

Commit

Permalink
reopened pr ThreeMammals#1030
Browse files Browse the repository at this point in the history
  • Loading branch information
Hille authored and raman-m committed May 11, 2023
1 parent bc25f4e commit 63a8709
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 @@ -48,13 +48,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 63a8709

Please sign in to comment.