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

Need an abort() method and a async close() method for Websockets #216

Open
glassfishrobot opened this issue Oct 28, 2013 · 3 comments
Open
Labels
API (Both) Impacts the client and server API enhancement Adding a new feature or improving an existing one
Milestone

Comments

@glassfishrobot
Copy link

In Websocket 1.0, the javax.websocket.Session class provides methods #getBasicRemote() and #getAsyncRemote() which returns different RemoteEndpoints for either sending message synchronously (RemoteEndpoint.Basic) or asynchronously (RemoteEndpoint.Async).

However, to close a Websocket session (send the closing handshake) the only method is javax.websocket.Session#close(...). As it is a synchronous method it may block if there is no window on the underlying TCP connection to send the closing handshake. This can be a problem for implementations that only use Async I/O for sending Websocket message which are then forced to use Sync/Blocking I/O for sending the closing handshake.
(For example, in .Net, there is System.Net.WebSockets.WebSocket#CloseOutputAsync() method that async closes the WebSocket session.)

Also, javax.websocket.Session does not have a method to abort a WebSocket connection immediately. This might be needed for an application that needs to disconnect a Client e.g. as DoS prevention (for example, when a connected client reads data from the underlying TCP connection very slowly so that the App needs to buffer more and more messages for that client, the application may want to immediately abort the WebSocket connection).
Currently this is not possible - the App would need to wait to be able to send the closing handshake.
(For example, in .Net there is System.Net.WebSockets.WebSocket#Abort() method that immediately aborts the WebSocket connection and cancels all pending I/O operations.)

Please see the thread on [1] for a discussion on Tomcat's Users list about these issues.

[1] http://markmail.org/message/z2pxdxeto656byu3

Affected Versions

[1.0]

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
Reported by preisser144

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
This issue was imported from java.net JIRA WEBSOCKET_SPEC-216

@glassfishrobot
Copy link
Author

@markt-asf markt-asf added API (Both) Impacts the client and server API enhancement Adding a new feature or improving an existing one Jakarta EE 10 and removed Priority: Major Type: Improvement labels May 7, 2020
@markt-asf markt-asf added this to the backlog milestone May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API (Both) Impacts the client and server API enhancement Adding a new feature or improving an existing one
Projects
None yet
Development

No branches or pull requests

2 participants