Skip to content
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

fix #970 Ensure WebSocket compression is enabled on the server in cases there is a compressionPredicate #971

Closed
wants to merge 1 commit into from

Conversation

violetagg
Copy link
Member

No description provided.

@amizurov
Copy link

@violetagg thx for reactive fix and in common case it works, but if we change configuration to

HttpServer server =
           HttpServer.create()
               .port(8080)
               .compress(false)
               .compress(2048)
               .wiretap(true)
               .route(r -> r.ws("/ws", (in, out) -> out.sendObject(in.receiveFrames().doOnNext(WebSocketFrame::retain))));

the WebSocket compression is applied because predicate present, looks unobvious. WDYT ?

@violetagg
Copy link
Member Author

violetagg commented Jan 24, 2020

@violetagg thx for reactive fix and in common case it works, but if we change configuration to

HttpServer server =
           HttpServer.create()
               .port(8080)
               .compress(false)
               .compress(2048)
               .wiretap(true)
               .route(r -> r.ws("/ws", (in, out) -> out.sendObject(in.receiveFrames().doOnNext(WebSocketFrame::retain))));

the WebSocket compression is applied because predicate present, looks unobvious. WDYT ?

There is kind of misunderstanding here
.compress(true) means compress always
then you override this setting with
.compress(2048) which mean stop compressing always (because this was the previous setting) and start compressing when this condition is met.

then the second example is
.compress(false) means DO NOT compress
then you override this setting with
.compress(2048) which mean start compressing when this condition is met.

https://projectreactor.io/docs/netty/release/reference/index.html#_compression

@amizurov
Copy link

@violetagg thx for reactive fix and in common case it works, but if we change configuration to

HttpServer server =
           HttpServer.create()
               .port(8080)
               .compress(false)
               .compress(2048)
               .wiretap(true)
               .route(r -> r.ws("/ws", (in, out) -> out.sendObject(in.receiveFrames().doOnNext(WebSocketFrame::retain))));

the WebSocket compression is applied because predicate present, looks unobvious. WDYT ?

There is kind of misunderstanding here
.compress(true) means compress always
then you override this setting with
.compress(2048) which mean stop compressing always (because this was the previous setting) and start compressing when this condition is met.

then the second example is
.compress(false) means DO NOT compress
then you override this setting with
.compress(2048) which mean start compressing when this condition is met.

Yes i understand this, but compression for http response and webSocket compression is not depend to each other, also i can use simultaneously ws and http and i want to configure each of them independently IMHO.

@violetagg
Copy link
Member Author

Yes i understand this, but compression for http response and webSocket compression is not depend to each other, also i can use simultaneously ws and http and i want to configure each of them independently IMHO.

We do not support that. If you want I can revert this change and we can treat your issue as a feature request.
wdyt?

@amizurov
Copy link

Yes i understand this, but compression for http response and webSocket compression is not depend to each other, also i can use simultaneously ws and http and i want to configure each of them independently IMHO.

We do not support that. If you want I can revert this change and we can treat your issue as a feature request.
wdyt?

Thx again for your time. I'm ok with this PR but we change behavior for org.springframework.boot.web.embedded.netty.NettyWebServer because before it websocket compression never work :). I agree that is a good idea to create separate feature request where we can improve current logic and clear api. Also we can improve websocket compression to selective approach (Netty suported this https://github.com/netty/netty/pull/8910/files/6bdf7ad8bf6c6f23111671fbaba7403ab38c53fe) and apply only to websocket frames by predicate like http does.

@violetagg
Copy link
Member Author

Thx again for your time. I'm ok with this PR but we change behavior for org.springframework.boot.web.embedded.netty.NettyWebServer because before it websocket compression never work :). I agree that is a good idea to create separate feature request where we can improve current logic and clear api. Also we can improve websocket compression to selective approach (Netty suported this https://github.com/netty/netty/pull/8910/files/6bdf7ad8bf6c6f23111671fbaba7403ab38c53fe) and apply only to websocket frames by predicate like http does.

@rstoyanchev wdyt? My opinion I that we should separate both configurations.

@rstoyanchev
Copy link
Contributor

Yes I think it would be a good idea to separate the two. Unless only compress(true) is used, the presence of any other compress predicate (size or custom), since it can't be evaluated properly, that makes it ambiguous whether it should even apply to WebSocket.

@violetagg
Copy link
Member Author

I'm closing this PR - we will NOT apply this fix.

There will be a WebSocket configuration for compression on/off.
For the WebSocketExtensionFilterProvider support I created a separate feature request #977

@violetagg violetagg closed this Jan 28, 2020
@violetagg violetagg removed this from the 0.8.16.RELEASE milestone Jan 28, 2020
@violetagg violetagg deleted the issue-970 branch January 28, 2020 18:38
@violetagg
Copy link
Member Author

new PR #980

@violetagg violetagg added the status/superseded An issue that has been superseded by another label Feb 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/superseded An issue that has been superseded by another
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants