Skip to content

Make WebSocket compression actually work#414

Open
robert-s-ubi wants to merge 2 commits intomasterfrom
fix_websocket_compression
Open

Make WebSocket compression actually work#414
robert-s-ubi wants to merge 2 commits intomasterfrom
fix_websocket_compression

Conversation

@robert-s-ubi
Copy link
Contributor

@robert-s-ubi robert-s-ubi commented Dec 24, 2025

A new PerMessageDeflateExtension was contributed to the Java-WebSocket
project, but no new release of that library has been made since.

Add a copy of the new implementation with an adapted package path and
use that instead of the old version from Java-WebSocket 1.6.0.

Add a new JSON configuration parameter "WEBSOCKET_MAX_FRAME_SIZE" to set
a limit for the maximum WebSocket frame size, as especially with the new
compression support, unbounded frame sizes pose a risk. The default is
left at 0 (unbounded) to keep compatibility with all existing uses, but
it is strongly recommended to set an appropriate limit.

Add a new API MultiProtocolJSONClient#getCompressionRatio() to retrieve
the current compression ratio for informational purposes.

Increase the WebSocket compression threshold from 0 to 64 bytes, as it
was observed that frames smaller than 64 bytes typically grow in size
when compression is applied.

A new PerMessageDeflateExtension was contributed to the Java-WebSocket
project, but no new release of that library has been made since.

Add a copy of the new implementation with an adapted package path and
use that instead of the old version from Java-WebSocket 1.6.0.

This is intended to be a temporary measure until a newer release of the
Java-WebSocket library is made. When that is updated, this change can be
reverted.
Add a new JSON configuration parameter "WEBSOCKET_MAX_FRAME_SIZE" to set
a limit for the maximum WebSocket frame size, as especially with the new
compression support, unbounded frame sizes pose a risk. The default is
left at 0 (unbounded) to keep compatibility with all existing uses, but
it is strongly recommended to set an appropriate limit.

Add a new API MultiProtocolJSONClient#getCompressionRatio() to retrieve
the current compression ratio for informational purposes.

Increase the WebSocket compression threshold from 0 to 64 bytes, as it
was observed that frames smaller than 64 bytes typically grow in size
when compression is applied.
@robert-s-ubi robert-s-ubi force-pushed the fix_websocket_compression branch from f525dd8 to 2574c41 Compare March 26, 2026 19:31
@robert-s-ubi
Copy link
Contributor Author

@TVolden could you maybe review this PR as well? It is mostly using the bugfixed websocket per-message implementation I contributed to the dependency project (TooTallNate/Java-WebSocket#1498) where it has been merged, but not released since. Since the current state is rather broken, I would not want to wait any longer for them to make a release to fix this library.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant