MultiServer: Await closing of websocket server - #6383
Open
exodustx0 wants to merge 4 commits into
Open
Conversation
Collaborator
|
I notice that the behavior for |
Author
This PR uses |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this fixing or adding?
MultiServer.py does not await closing of its websocket server, leading to non-graceful disconnections of connected clients. Ironically, the only way for a MultiServer to gracefully close a connection with a client, is if a network protocol packet sent by the client causes an Exception in the MultiServer. This PR lets a MultiServer gracefully disconnect clients.
I did a search through the repository to see if there are other occurrences of closing a server not being awaited, and there are indeed two clients for apworlds (
ahitandladx) create websocket servers of their own which don't even try to close the server, let alone wait for it. The latter does comment that its server should run forever, though. Naturally acting on this is out of scope for this PR (as well as me not being the right person to act on it), but I figured making note of it would allow a world maintainer to act on it if deemed necessary.How was this tested?
Running a server locally, connecting a client and using the
/exitcommand on the server; additionally, running a server locally with--auto-shutdown=10, connecting a client and waiting 10 seconds. In both cases, when observing the websocket close error code received at the client, before this change the code is 1006 (Abnormal Closure), and after, the code is 1001 (Going Away).If this makes graphical changes, please attach screenshots.
N/A