Skip to content

fixes bug with incorrect WS framesize setup. #610

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

Merged
merged 6 commits into from
Apr 2, 2019

Conversation

OlegDokuka
Copy link
Member

@OlegDokuka OlegDokuka commented Apr 1, 2019

This PR provides a WebSocket transport's frame size setup with regards
of current RSocket fragment size.

Signed-off-by: Oleh Dokuka [email protected]

This PR provides a websocket transport's frame size setup with regards
of current RSocket fragment size.

Current implementation provides the following setup rules:

 * if `mtu` is 0 (means no fragmentation) - then WS frame size is equal to
   maximum default frame size of RSocket frame which is `16_777_215`;
 * if `mtu` is GT > 0 and LT < 65536 (default for WS frame size) then
   the WS frame size will be its the default one (which is `65536`);
 * if `mtu` is GT > 65536 then the WS frame size will be set to
   the specified by that parameter size

Signed-off-by: Oleh Dokuka <[email protected]>
})
.bind()
.map(CloseableChannel::new);
}

static final class UriPathTemplate {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is port from Reactor-Netty internals

cc/
@violetagg

Signed-off-by: Oleh Dokuka <[email protected]>
@@ -114,6 +118,8 @@ public void setTransportHeaders(Supplier<Map<String, String>> transportHeaders)
(request, response) -> {
transportHeaders.get().forEach(response::addHeader);
return response.sendWebsocket(
null,
Math.max(DEFAULT_FRAME_SIZE, mtu == 0 ? FRAME_MAX_SIZE : mtu),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this doing? Is there a reason we are setting the max frame size to anything but rsocket max frame size?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, the entire fragmentation logic is built on top of the assumption that mtu is higher than 0. So if mtu is 0, then fragmentation is avoided. It means that max size of the fragment should be less || equal to maximum possible size frame. At least I was thinking like that when writing that code. In case 0xFFFFFF is a specific limit to fragmentation and in general payload size is unlimited (or limited to (Integer.MAX_VALUE - 2)), then I can fix that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simplified to max frame size for all possible cases

@robertroeser robertroeser merged commit ab46669 into develop Apr 2, 2019
mostroverkhov pushed a commit that referenced this pull request Apr 5, 2019
* fixes buf with incorrect WS framesize setup.

This PR provides a websocket transport's frame size setup with regards
of current RSocket fragment size.

Current implementation provides the following setup rules:

 * if `mtu` is 0 (means no fragmentation) - then WS frame size is equal to
   maximum default frame size of RSocket frame which is `16_777_215`;
 * if `mtu` is GT > 0 and LT < 65536 (default for WS frame size) then
   the WS frame size will be its the default one (which is `65536`);
 * if `mtu` is GT > 65536 then the WS frame size will be set to
   the specified by that parameter size

Signed-off-by: Oleh Dokuka <[email protected]>

* rollbacks commented docs build

* fixes format

Signed-off-by: Oleh Dokuka <[email protected]>

* cleanup pollution uses max frame size from  `FrameLengthFlyweight`

Signed-off-by: Oleh Dokuka <[email protected]>

* simplifies logic of max frame size setup for ws transport

Signed-off-by: Oleh Dokuka <[email protected]>

* fixes google java format

Signed-off-by: Oleh Dokuka <[email protected]>
Signed-off-by: Maksym Ostroverkhov <[email protected]>
OlegDokuka added a commit that referenced this pull request May 29, 2019
robertroeser pushed a commit that referenced this pull request Jun 6, 2019
* backports fixes bug with incorrect WS framesize setup (#614)

* rollback mockito version

* changed timeout

* changed timeout

* small fix

* replace with concurrent maps

Signed-off-by: Oleh Dokuka <[email protected]>
@robertroeser robertroeser deleted the bugfix/ws-frame-size-configuration branch July 10, 2019 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants