Closed sniggyfigbat closed 2 years ago
System.InvalidOperationException: "Can't disconnect when client isn't connected."
That happens if disconnect is called when you have already disconnected from Lavalink.
System.InvalidOperationException: "WebSocket is not in open state. Current state: CloseSent".
If Victoria is connected to Lavalink then that error shouldn't happen but if you disconnected and tried performing any operation or the send queue wasn't empty then that could happen.
ASP.NET does expose a way to take care of this and you can combine it with Victoria to handle disconnects gracefully. Use the Lavalink.IsConnected
property to check whether you're connected before calling DisconnectAsync
or DisposeAsync
in conjunction with https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.hosting.iapplicationlifetime.applicationstopping?view=aspnetcore-6.0
Gonna close this issue since no response.
Describe your issue in as much detail as possible
When I shut down my .NET program, Victoria seems to throw exceptions.
System.InvalidOperationException: "Can't disconnect when client isn't connected."
System.InvalidOperationException: "WebSocket is not in open state. Current state: CloseSent"
.The program is a pretty straightforward .NET setup, using Victoria pretty close to the examples but with a few extra features. The exceptions get thrown when shutting down by pressing
Ctrl-C
in the console, and get thrown at theIHost
run line:It's entirely possible that this is user-error on my end, but I'm not spotting any safe-shutdown-related code in the v5 example that I might have missed. Interestingly, I just discovered that .NET doesn't seem to call
IDisposable
on services on shutdown if the program is ended abruptly by closing the console window, which may be why more people haven't encountered this.When Lavalink isn't connected
Full stack trace for "Can't disconnect when client isn't connected.":
When Lavalink is connected
Full stack trace for "WebSocket is not in open state. Current state: CloseSent":
Version
v5 (Latest)
Version
GitHub's latest
Relevant log output
No response