-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/websocket closeoutput exceptions #1030
Feature/websocket closeoutput exceptions #1030
Conversation
Shouldn't we add the same check to line 68? |
I assume you mean to check the connection state when a close message has been recieved? I guess it should not matter as the connection will be closed anyway with the message, the only difference should be the modified status (not sure where this is used). Have you thought of any cases where this is relevant? If so please let me know and I will fix it. |
Currently we have the ocelot in production with this PR applied. And still get same exceptions. As far I see, this is the place, where it could be thrown. |
Didn't help :( |
please open PR again against master branch |
From Rubbiroid on Jan 13, 2020
@Rubbiroid |
Hi @tdejong-tools4ever ! |
I have merged the pr, but still got the same exception. Right now I do not have logs anymore. |
Hey @raman-m, Back then we had a reproduction scenario with our wamp service websocket being routed through ocelot causing the issue I am sorry but I am no longer be able to help you with this reproducing this issue. |
@tdejong-tools4ever You and your team could try latest 19.0.2 release of Ocelot NuGet package (.NET 7 release). |
Fixes / New Feature #
Fixes exceptions being thrown because of already closed WebSockets when the state is both updated by the source and destination.
Proposed Changes
Stacktrace of exception that is intended to fix:
requestId: 0HLPTRFNQ4IJE:00000001, previousRequestId: no previous request id, message: Exception caught in global error handler, exception message: The WebSocket is in an invalid state ('Aborted') for this operation. Valid states are: 'Open, CloseReceived', exception stack: at System.Net.WebSockets.WebSocketValidate.ThrowIfInvalidState(WebSocketState currentState, Boolean isDisposed, WebSocketState[] validStates) at System.Net.WebSockets.ManagedWebSocket.CloseOutputAsync(WebSocketCloseStatus closeStatus, String statusDescription, CancellationToken cancellationToken) --- End of stack trace from previous location where exception was thrown --- at Ocelot.WebSockets.Middleware.WebSocketsProxyMiddleware.PumpWebSocket(WebSocket source, WebSocket destination, Int32 bufferSize, CancellationToken cancellationToken) at Ocelot.WebSockets.Middleware.WebSocketsProxyMiddleware.Proxy(HttpContext context, String serverEndpoint) at Ocelot.WebSockets.Middleware.WebSocketsProxyMiddleware.Invoke(DownstreamContext context) at Ocelot.DownstreamUrlCreator.Middleware.DownstreamUrlCreatorMiddleware.Invoke(DownstreamContext context) at Ocelot.LoadBalancer.Middleware.LoadBalancingMiddleware.Invoke(DownstreamContext context) at Ocelot.Request.Middleware.DownstreamRequestInitialiserMiddleware.Invoke(DownstreamContext context) at Ocelot.Middleware.Multiplexer.Multiplexer.Fire(DownstreamContext context, OcelotRequestDelegate next) at Ocelot.Middleware.Multiplexer.Multiplexer.Multiplex(DownstreamContext context, ReRoute reRoute, OcelotRequestDelegate next) at Ocelot.DownstreamRouteFinder.Middleware.DownstreamRouteFinderMiddleware.Invoke(DownstreamContext context) at Ocelot.Middleware.Pipeline.MapWhenMiddleware.Invoke(DownstreamContext context) at Ocelot.Errors.Middleware.ExceptionHandlerMiddleware.Invoke(DownstreamContext context)