Skip to content

Add configuration option to customize RSocketServer's fragment size #23247

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

Closed
srinivasvsk opened this issue Sep 3, 2020 · 6 comments
Closed
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@srinivasvsk
Copy link

The documentation is not clear how to set the max frame payload size, all questions are pointing to cloud gateway. Currently we are not using gateway and just using rsocker server.
Thanks

@philwebb philwebb transferred this issue from spring-projects/spring-boot Sep 4, 2020
@rstoyanchev
Copy link
Contributor

rstoyanchev commented Sep 10, 2020

@philwebb I think this relates entirely to Spring Boot where the RSocket server is configured and started.

@srinivasvsk I'm not sure if your goal is to fragment large RSocket Payloads, or to limit the frame size at the WebSocket transport level? For the former you can set RSocketServer#fragment via RSocketServerCustomizer. For the latter you'd need to customize RSocket's WebsocketServerTransport. In the upcoming RSocket Java 1.1 there is a convenient method to do this but in RSocket 1.0.x you'd have to override the start method. In either case, however I don't see any option to customize the transport in Boot which is created privately in NettyRSocketServerFactory.

@srinivasvsk
Copy link
Author

Thanks for more details, my use case is to pass a large payload, process and stream results back. Had the server complained about 6500 limit. can you point to more information on RSocketServerCustomizer

@bclozel
Copy link
Member

bclozel commented Sep 10, 2020

@srinivasvsk I guess you're referring to 65536 default limit on the websocket frame payload length - see reactor.netty.http.websocket.WebsocketSpec. I think Rossen was pointing out at another configuration, which is about the maximum inbound payload size on the server (which is at Integer.MAX_VALUE, see io.rsocket.core.RSocketServer.

For your current application, you'll need override the start method for your server and create your own server bean unfortunately. The RSocketServerCustomizer cannot help you here.

Spring Boot 2.4 will be based on RSocket Java 1.1 and Spring Boot could provide a callback to customize the chosen transport mechanism thanks to the new convenient method.

After this discussion, I'm re-transferring this issue to Spring Boot and re-purposing it to "Allow RSocket transport customization".

Thanks!

@bclozel bclozel transferred this issue from spring-projects/spring-framework Sep 10, 2020
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 10, 2020
@bclozel bclozel added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 10, 2020
@bclozel bclozel added this to the 2.4.x milestone Sep 10, 2020
@bclozel bclozel changed the title rsocket / websocket how to set max frame payload size Allow RSocket transport customization Sep 10, 2020
@rstoyanchev
Copy link
Contributor

@bclozel yes one option is to increase the WebSocket frame size at the transport level in Reactor Netty. Isn't it also an option to enable fragmentation of large Payload's at the RSocket level via RSocketServerCustomizer? That would get the Payload through as well without changing the WebSocket frame size.

@bclozel
Copy link
Member

bclozel commented Sep 11, 2020

Right!

@srinivasvsk

In the meantime, you can declare an RSocketServerCustomizer in your Spring Boot application like this:

@Configuration(proxyBeanMethods = false)
public class RSocketConfig {

  @Bean
  public RSocketServerCustomizer fragmentationCustomizer() {
    return (server) -> server.fragment(16384); // use a non-zero value that tells the server to fragment messages at this size
    // you should use a value that's not too small to avoid overhead, but not larger than the `65536` websocket max frame size
  }

}

@srinivasvsk
Copy link
Author

Great thank you all

@snicoll snicoll self-assigned this Oct 5, 2020
@snicoll snicoll changed the title Allow RSocket transport customization Add configuration option to customize RSocketServer's fragment size Oct 5, 2020
@snicoll snicoll modified the milestones: 2.4.x, 2.4.0-M4 Oct 5, 2020
@snicoll snicoll closed this as completed in ebc9c57 Oct 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants