WebSocket error handling

0
0

I am experiencing strange web socket errors. is there a way to create a handler that would help me determine if this is caused by timeouts or something else ?

How wisej is handling “sessionTimeout” from Default.json, could this be connected to this web socket errors ?

Another question is how you can restart non managed app pool, sometimes if I try to do it from IIS console I am just getting Event Viewer log file failed to stop app pool.

This is

fail: Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer[2]
Connection ID “15348267531689264185”, Request ID “8000043a-0000-d500-b63f-84710c7967bb”: An unhandled exception was thrown by the application.
System.Net.WebSockets.WebSocketException (0x80004005): The remote party closed the WebSocket connection without completing the close handshake.
at System.Net.WebSockets.ManagedWebSocket.ThrowEOFUnexpected()
at System.Net.WebSockets.ManagedWebSocket.EnsureBufferContainsAsync(Int32 minimumRequiredBytes, CancellationToken cancellationToken)
at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
at System.Net.WebSockets.ManagedWebSocket.ReceiveAsyncPrivate[TResult](Memory`1 payloadBuffer, CancellationToken cancellationToken)
at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
at System.Threading.Tasks.ValueTask`1.ValueTaskSourceAsTask.<>c.<.cctor>b__4_0(Object state)
— End of stack trace from previous location —
at Wisej.Core.HttpHandler.ProcessWebSocketRequest(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT`1.ProcessRequestAsync()

  • You must to post comments
0
0

Hi Dino,

in order to help you and investigate this we need a reproducible test case.

Best regards
Frank

  • Dino Novak
    Hi unfortunately I am not successful in creating a test case where this would consistently pop us as problem, but let me share with you what is in place in order to try to catch this: 1) We are restarting app pool daily before each workday in order to remove potential memory issues 2) we do not see significant memory utilisation that could be linked to this error 3) we are running app in non managed app pool with latest .net 8 and wisej binaries 4) we tried running app with websockets enabled and disabled and in both cases this error pops up 5) binary is configured in web.config to run with stdoutLogEnabled=”true” stdoutLogFile=”.\logs\stdout” hostingModel=”inprocess” and with 6) In program.cs we have serology enabled with log to file and are defining thread handler Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) { // Log the exception or show a message to the user LogException(e.Exception); ShowErrorMessage(e.Exception); } 7) in startup.cs we added app.UseExceptionHandler( options => { options.Run( async context => { context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; context.Response.ContentType = “text/html”; var ex = context.Features.Get(); if (ex != null) { Log.Error($”Error: {ex.Error.Message} : {ex.Error.StackTrace}”); var err = $”Error: {ex.Error.Message}{ex.Error.StackTrace}”; await context.Response.WriteAsync(err).ConfigureAwait(false); } }); } ); And unfortunately we are unable to trace any appearance of this error. So any advice from your side would be more than welcomed.
  • You must to post comments
0
0

It’s not an error to be handled and cannot be handled, it’s already managed by the System.Net.WebSocket library which is not part of Wisej. It’s a normal occurrence for the System.Net.WebSockets.ManagedWebSocket. You found it in the event viewer, not in the application. It’s the websocket throwing an exception of a connection terminated for a variety of reasons.

 

Julie

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.