You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unfortunately, the recently added WebSocket compression support is broken due to a bug in the Java-WebSocket library (TooTallNate/Java-WebSocket#1496).
If WebSocket compression is enabled on a MultiProtocolJSONClient, the second message exchange with the MultiProtocolJSONServer yields an exception:
org.java_websocket.exceptions.InvalidDataException: invalid distance too far back
at org.java_websocket.extensions.permessage_deflate.PerMessageDeflateExtension.decodeFrame(PerMessageDeflateExtension.java:193)
at org.java_websocket.drafts.Draft_6455.translateSingleFrame(Draft_6455.java:589)
at org.java_websocket.drafts.Draft_6455.translateFrame(Draft_6455.java:762)
at org.java_websocket.WebSocketImpl.decodeFrames(WebSocketImpl.java:394)
at org.java_websocket.WebSocketImpl.decode(WebSocketImpl.java:229)
This can be worked around by changing the PerMessageDeflation configuration in MultiProtocolJSONClient perMessageDeflateExtension.setServerNoContextTakeover(false -> true), but that yields a much lower compression efficiency.
I don't know if or when this PR will be picked up, and when that might be released. In the meantime, if you want to use WebSocket compression, you can either compile this library from source with the modification mentioned above, or compile the Java-WebSocket library from source with the above PR patched in and use this library unmodified. The latter solution yields much higher compression efficiency (at the cost of higher memory usage).
Note that the MultiProtocolJSONServer from release 2.0 enables WebSocket compression by default using the buggy Java-WebSocket implementation, which WILL cause problems with clients supporting WebSocket compression as well.
As a workaround, disable WebSocket compression by passing a JSONConfiguration object to MultiProtocolJSONServer created like this:
Activity
robert-s-ubi commentedon Dec 19, 2025
I have submitted a PR to the Java-WebSocket library to fix the issue on their end:
TooTallNate/Java-WebSocket#1497
I don't know if or when this PR will be picked up, and when that might be released. In the meantime, if you want to use WebSocket compression, you can either compile this library from source with the modification mentioned above, or compile the Java-WebSocket library from source with the above PR patched in and use this library unmodified. The latter solution yields much higher compression efficiency (at the cost of higher memory usage).
robert-s-ubi commentedon Dec 24, 2025
The fix above is actually not enough, so I wrote a new implementation from scratch, which is available as a PR here:
#414
I will also contribute this to the Java-WebSocket project, but them picking it up and making a bugfixed release might take a while.
robert-s-ubi commentedon Dec 24, 2025
Note that the MultiProtocolJSONServer from release 2.0 enables WebSocket compression by default using the buggy Java-WebSocket implementation, which WILL cause problems with clients supporting WebSocket compression as well.
As a workaround, disable WebSocket compression by passing a JSONConfiguration object to MultiProtocolJSONServer created like this:
JSONConfiguration.get().setParameter(JSONConfiguration.WEBSOCKET_COMPRESSION_SUPPORT, false);
In MultiProtocolJSONClient, the default is disabled, so unless you are explicitly enabling it, there is no precaution to take.
robert-s-ubi commentedon Mar 31, 2026
The PR to fix this has been merged, but there is no release with this fix yet. Build the current master to get a fixed version.