Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Recent alerts have shown uncaught exceptions for clients using the WebSockets connection method. Two main issues were identified.
Write to closed WebSocket
In some circumstances the WebSocket might close unexpectedly. If the server tried to write data to this port an unhandled exception would be thrown.
An investigation led to this issue websockets/ws#1515.
This PR adds better error and closed socket handling to the
WebSocketDuplexConnection
andWebSocketServerTransport
implementations provided by RSocket.A unit test has been added to ensure no unhandled exceptions are thrown when the client closes the WebSocket.
Undefined frames
Some reports of the server failing to handle WebSocket frames were received.
This was reproducible by sending invalid data (not a valid RSocket frame buffer) over a WebSocket. Although not verified: this might be caused by a broken
Buffer
implementation on the client side which could happen in environments such as React Native.Additional guards have been added to the
WebSocketDuplexConnection
frame handling. Unit tests have also been added for invalid frames.Double close warning
Previously a double close warning for the RSocket server could be seen in logs. Currently we use a Fastify server which a WebSocket server manages
upgrade
events on. The standard RSocketWebSocketServerTransport
registers a listener for theclose
event of the WebSocketServer and calls theServerCloseable
close
wherein the server is again closed. This behaviour has been removed as the WebSocket server's closing is tied to the Fastify server'sclose
event.Additional Fixes
This PR includes some additional bug fixes:
path
references for theserver
project..probes
folder forservice
folder