Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gracefully close open WebSocket connections when server shuts down. #77

Open
aslakhellesoy opened this issue Feb 14, 2012 · 7 comments
Open

Comments

@aslakhellesoy
Copy link
Member

When the server shuts down it should call WebSocketConnection.close() on all open connections. This will send a CLOSE frame to the connected client, preventing IO exceptions in the clients.

@aslakhellesoy
Copy link
Member Author

Might be related to #41

@aslakhellesoy
Copy link
Member Author

As part of doing this we should probably add a WebSokcetHandler.onError event, so that we can test how a connection is closed on the client (we'd expect a close event, but not an error event).

@KushalP
Copy link
Contributor

KushalP commented Feb 14, 2012

Should this also attempt to "catch" exceptions and do WebSocketConnection.close() rather than just leaving them hanging as well?

@aslakhellesoy
Copy link
Member Author

@KushalP do you mean IO exceptions or other exceptions? Got an example? What do you mean by leaving them hanging?

@KushalP
Copy link
Contributor

KushalP commented Feb 14, 2012

Yes. In the case of IO exceptions, should we catch them (provisionally) to close the WebSocket connections and then throw the IO exception back out?

My thinking behind this is to prevent clients from attempting to communicate with a server that has failed.

@aslakhellesoy
Copy link
Member Author

I'm still not sure I understand...

  1. A client establishes a WebSocket connection.
  2. The server catches an IO exception while trying to read from or write to the client's socket.
  3. The server calls close() on the associated connection object so a CLOSE frame can be sent back to the client.

I don't understand how this would work. We wouldn't get an IO exception unless the socket is hosed, in which case we can't send a CLOSE frame at all.

Am I missing something here?

(IO exceptions are already caught and sent to the WebServer.connectionExceptionHandler)

@KushalP
Copy link
Contributor

KushalP commented Feb 14, 2012

Perhaps this is a bit silly to try and pull off in practice.

Don't worry about this for the moment. I'll have a proper think (and look through the spec) and get back to you if this is feasible.

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

No branches or pull requests

2 participants