Skip to content

is WebSocketServer missing a close method? #7

Closed

Description

@belm0

I'm looking for a way to close WebSocketServer so it ends its connections.

Activity

  1. mehaase commented on Sep 14, 2018

    @mehaase
    Contributor

    I started to work on this and got stuck. The expected behavior isn't 100% obvious. What do we think this API should do? My initial idea was:

    • WebSocketServer inherits from AsyncResource
    • WebSocketServer.aclose():
      • Cancels the listener
      • Calls aclose() on each open connection
      • Returns when the listener and all associated tasks have exited.

    This approach was a bit tricky to pull off, and after talking about it on Gitter, I realized that I hadn't considered what to do with each connection handler. Should handlers be cancelled? Should we wait for handlers to exit on their own?

    If we close a handler's WebSocket, it should raise ConnectionClosed, which would allow each handler to clean up and exit. (But to make this robust, #11 needs to be fixed.) This is roughly what I have already implemented, and I think I favor this approach. What do you think?

  2. njsmith commented on Sep 15, 2018

    @njsmith
    Member

    @belm0 What are you trying to do that's different then just cancelling the server?

  3. belm0 commented on Sep 15, 2018

    @belm0
    MemberAuthor

    Cancel is fine I think. I'd like to see how this works in practice with the new API.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions