Skip to content

MultiServer: Await closing of websocket server - #6383

Open
exodustx0 wants to merge 4 commits into
ArchipelagoMW:mainfrom
exodustx0:await_ws_server_close
Open

MultiServer: Await closing of websocket server#6383
exodustx0 wants to merge 4 commits into
ArchipelagoMW:mainfrom
exodustx0:await_ws_server_close

Conversation

@exodustx0

Copy link
Copy Markdown

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 (ahit and ladx) 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 /exit command 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

@github-actions github-actions Bot added affects: core Issues/PRs that touch core and may need additional validation. waiting-on: peer-review Issue/PR has not been reviewed by enough people yet. labels Aug 7, 2026
@duckboycool duckboycool added the is: bug/fix Issues that are reporting bugs or pull requests that are fixing bugs. label Aug 7, 2026
@duckboycool

Copy link
Copy Markdown
Collaborator

I notice that the behavior for wait_closed apparently changed in 3.12. Would that affect the functionality here for the currently still supported 3.11?

@exodustx0

Copy link
Copy Markdown
Author

I notice that the behavior for wait_closed apparently changed in 3.12. Would that affect the functionality here for the currently still supported 3.11?

This PR uses websockets.WebSocketServer.wait_closed, not asyncio.Server.wait_closed! That change won't affect us here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

affects: core Issues/PRs that touch core and may need additional validation. is: bug/fix Issues that are reporting bugs or pull requests that are fixing bugs. waiting-on: peer-review Issue/PR has not been reviewed by enough people yet.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants