Hastwell / Omukade.Cheyenne

Pokemon TCG Live (Rainier) 3rd Party Server
GNU Affero General Public License v3.0
10 stars 2 forks source link

Unhandled exception. System.ObjectDisposedException: IFeatureCollection has been disposed. #3

Open Hill-98 opened 7 months ago

Hill-98 commented 7 months ago
Unhandled exception. System.ObjectDisposedException: IFeatureCollection has been disposed.
Object name: 'Collection'.
   at Microsoft.AspNetCore.Http.Features.FeatureReferences`1.ThrowContextDisposed()
   at Microsoft.AspNetCore.Http.Features.FeatureReferences`1.Fetch[TFeature](TFeature& cached, Func`2 factory)
   at Microsoft.AspNetCore.Http.DefaultHttpContext.Abort()
   at Microsoft.AspNetCore.WebSockets.ServerWebSocket.Abort()
   at Omukade.Cheyenne.Miniserver.Controllers.StompController.Dispose() in C:\Users\Hill\Desktop\Omukade.Cheyenne\Omukade.Cheyenne\Miniserver\Controllers\StompController.cs:line 194
   at Omukade.Cheyenne.Miniserver.Controllers.StompController.DisconnectClientImmediately() in C:\Users\Hill\Desktop\Omukade.Cheyenne\Omukade.Cheyenne\Miniserver\Controllers\StompController.cs:line 189
   at Omukade.Cheyenne.Program.ProcessSingleWsMessage(ReceivedMessage messageWrapper) in C:\Users\Hill\Desktop\Omukade.Cheyenne\Omukade.Cheyenne\Program.NativeWs.cs:line 233
   at Omukade.Cheyenne.Program.WebsocketCheynneThread() in C:\Users\Hill\Desktop\Omukade.Cheyenne\Omukade.Cheyenne\Program.NativeWs.cs:line 150
   at System.Threading.Thread.StartCallback()

Is it possible to change the following code?

public void Dispose()
{
    this.ws.Abort();
    this.ws.Dispose();
}
public void Dispose()
{
    try
    {
        this.ws.Abort();
        this.ws.Dispose();
    }
    catch (Exception e)
    {
        AnsiConsole.WriteException(e);
    }
}
Hastwell commented 7 months ago

This stacktrace suggests there are really two issues:

  1. I overlooked a failure condition when forcibly terminating a client's connection. This seemed to be reliable enough in testing, but is clearly not the case. 😛
  2. The call to DisconnectClientImmediately from ProcessSingleMessage suggests the server is receiving a message that is causing an exception, and is trying to log it and disconnect you. There should be a second stacktrace logged right before this one with details on that. I would also be interested in what the client was doing to cause this, and if there is a consistent bug repro. Please report your findings there as a separate bug to keep this thread on-topic.
Hill-98 commented 7 months ago

I have no way of knowing what the client is doing at the moment, as I run a community server using this, and it may be that one of the users has done something to cause this.

Maybe I'll have added some tracing to the code afterward in order to learn that it was that user who threw the exception.