This is a question to verify my understanding.
I find the value for maximum frame size hard coded into ReactorNettyWebSocketSession org.springframework.web.reactive.socket.adapter.ReactorNettyWebSocketSession.receive() and other classes use this class by creating new instances, leaving very cumbersome way of overriding beans to configure the frame size value.
I have got it to work by overriding the ReactorNettyWebSocketSession bean and redeclaring it.
I thunk it will need code updates within the spring cloud gateway code base to allow picking up the value from configuration in a simpler manner.
Can you explain more what you did? I can't find a bean declaration of ReactorNettyWebSocketSession anywhere.
GatewayAutoConfiguration.websocketRoutingFilter declares the filter bean
reactorNettyWebSocketClient() creates the client bean, webSocketService() too.
ReactorNettyWebSocketClient has new ReactorNettyWebSocketSession(in, out, info, factory) hardcoded.
ReactorNettyRequestUpgradeStrategy has new ReactorNettyWebSocketSession(in, out, info, bufferFactory) hardcoded.
I had to extend these two classes to allow the frame size value be set and then create new instance of webroutingfilter with these custom beans.
On the source, I think 1. there should be a a common wesbockets properties. 2. have these classes check them for config before falling back to defaults.
I'm still confused about what you think the gateway should do. All of those classes are from reactor netty. I have no plans to extend either one. If you think they need to be configurable, open an issue in reactor-netty and then maybe we can take advantage of it.
I also found the value for maximum frame size hard coded.
When I am using ReactorNettyWebSocketClient is there any way to configure that value? Would be hard to do it like the way @saiyedzaidi mentioned.
@saiyedzaidi @tonyskulk I think you'll need to open an issue with spring-framework to allow setting a value. @rstoyanchev thoughts?
@saiyedzaidi I suspect you're referring to this but that's size for aggregateFrames feature of Reactor Netty, and it doesn't change the underlying max frame size in Netty. We have a ticket to make that configurable in the Spring Framework but it depends on Reactor Netty exposing the property in the first place.
Thanks @rstoyanchev. I'm watching the framework ticket and https://github.com/reactor/reactor-netty/issues/223. This will be on hold until then.
Thanks @spencergibb and @rstoyanchev. I am watching both tickets, too.
I found that the problem is fixed by SpringBoot 2.1.0.RELEASE and Greenwich.M2. But I don't know how to set max frame size on websockets? Can anyone help? Thanks very much.
Hi @spencergibb , Did this issue have fixed and milestone? Thank you.
This is now dependent on https://github.com/spring-projects/spring-framework/pull/22328
I tried the milestone builds.
In ReactorNettyWebSocketClient the property is correctly set from the application properties.
But in ReactorNettyRequestUpgradeStrategy the value is not set. GatewayAutoConfiguration initiates the HandshakeWebSocketService (in Bean "webSocketService") without constructor parameter UpgradeStrategy.
(@saiyedzaidi mentioned this, too)
I had to extend GatewayAutoConfiguration's bean webSocketService, instantiate a new ReactorNettyUpgradeStrategy, set MaxFramePayloadLength in there and pass it to the HandshakeWebSocketService constructor.
Shouldn't that be part of the fix, too?
Thank you
I tried the milestone builds.
In ReactorNettyWebSocketClient the property is correctly set from the application properties.But in ReactorNettyRequestUpgradeStrategy the value is not set. GatewayAutoConfiguration initiates the HandshakeWebSocketService (in Bean "webSocketService") without constructor parameter UpgradeStrategy.
(@saiyedzaidi mentioned this, too)I had to extend GatewayAutoConfiguration's bean webSocketService, instantiate a new ReactorNettyUpgradeStrategy, set MaxFramePayloadLength in there and pass it to the HandshakeWebSocketService constructor.
Shouldn't that be part of the fix, too?
Thank you
Hi, could you explain how to extend GatewayAutoConfiguration?
@dkwasniak can you please open a new issue with how to recreate the problem?
@dkwasniak
@Configuration
@Import(GatewayAutoConfiguration.class)
public class CustomGatewayAutoConfiguration extends GatewayAutoConfiguration {
public CustomGatewayAutoConfiguration() {
}
@Override
@Bean
public WebSocketService webSocketService() {
ReactorNettyRequestUpgradeStrategy reactorNettyRequestUpgradeStrategy = new ReactorNettyRequestUpgradeStrategy();
reactorNettyRequestUpgradeStrategy.setMaxFramePayloadLength(10485760);
return new HandshakeWebSocketService(reactorNettyRequestUpgradeStrategy);
}
}
The original issue was for the WebSocketClient created in GatewaAutoConfiguraiton while @yves1982 is raising the same point but for the server side WebSocketService in the same configuration which should be created with a customized RequestUpgradeStrategy as the code snippet above shows.
@yves1982 it's probably best to create a new issue indeed as this one is already tied to a fix that has been released.
Most helpful comment
@saiyedzaidi I suspect you're referring to this but that's size for
aggregateFramesfeature of Reactor Netty, and it doesn't change the underlying max frame size in Netty. We have a ticket to make that configurable in the Spring Framework but it depends on Reactor Netty exposing the property in the first place.