-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Question: How can the compression threshold be set for the PerMessageDeflateExtension in a Deflate Client? #1437
Comments
setThreshold should do what you want |
Could you give an example of using that method please? |
It's not obvious how it should be called. |
Question is answered |
Actually I am not sure it is solved - from a brief look I didn't see a way for user to access the internal objects. But at the moment I don't have a lot of time and this is a low priority issue. It's possible we need to add a setter for this. |
What internal classes do you mean? |
Oh I see the problem. The values are not correctly cloned. Looking into copyInstance(), the fix for us for the specific issue is easy. @PhilipRoman I think about removing setInflater/setDeflater and replace them with a specific factory which the user can provide if they want to. |
I would prefer to fix setInflater/setDeflater. It is in fact not hard to do: Replace the inflater.end() + new Inflater() lines with inflater.reset(), and do the same for the deflater. Then the set inflater/deflater objects remain preserved. I tried that and it worked correctly for me. |
@CommuniG8 here is example how to use setTimeout: PerMessageDeflateExtension ext = new PerMessageDeflateExtension();
ext.setThreshold(...);
Draft perMessageDeflateDraft = new Draft_6455(ext);
// then just pass the Draft object to websocket server/client constructor
new WebSocketClient(..., perMessageDeflateDraft)
new WebSocketServer(..., Collections.singletonList(perMessageDeflateDraft)) Once the bug is fixed this should work @marci4 I don't have a strong opinion either way |
I am not doing a lot of java in my daily work, so please forgive me.
|
If the user hands in a deflater/inflater instance, the user takes control of the compression. It might not be PKZIP or GZIP at all. So I think it makes no difference that the user has control over this parameter. Or in other words: It is the user's responsibility to hand in an instance with compatible compression. |
Let us move the discussion to the PR. |
Describe what you would like to know or do
I'd like to be able to set the compression threshold to a lower value than the 1024 byte value in the PerMessageDeflateExtension.
Describe the solution you'd considered
I've taken a copy of the 1.5.7 source code and changed the default threshold which does work but this is not ideal.
Additional context
I'm sending messages which are a little smaller than 1024 bytes that I'd like to compress.
The text was updated successfully, but these errors were encountered: