jakartaee / jakartaee/websocket
Need an abort() method and a async close() method for Websockets
- Dominant language
- Java
- Stars
- 78
- Forks
- 47
- Avg merge
- 1h 32m
- Merged PRs (30d)
- 1
Description
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](http://markmail.org/message/z2pxdxeto656byu3)
#### Affected Versions
[1.0]
Contributor guide
Research direction
Start with the javax.websocket.Session API described in the issue and read the linked Tomcat Users discussion for the async close and immediate abort requirements. Define the API behavior and compatibility implications for both operations; done means the proposal is agreed and the relevant Session changes are covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100