org.springframework.web.reactive.socket.server.upgrade

Class ReactorNettyRequestUpgradeStrategy

  • java.lang.Object
    • org.springframework.web.reactive.socket.server.upgrade.ReactorNettyRequestUpgradeStrategy
    • Constructor Detail

      • ReactorNettyRequestUpgradeStrategy

        public ReactorNettyRequestUpgradeStrategy()
    • Method Detail

      • setMaxFramePayloadLength

        public void setMaxFramePayloadLength(java.lang.Integer maxFramePayloadLength)
        Configure the maximum allowable frame payload length. Setting this value to your application's requirement may reduce denial of service attacks using long data frames.

        Corresponds to the argument with the same name in the constructor of WebSocketServerHandshakerFactory in Netty.

        By default set to 65536 (64K).

        Parameters:
        maxFramePayloadLength - the max length for frames.
        Since:
        5.1
      • getMaxFramePayloadLength

        public int getMaxFramePayloadLength()
        Return the configured max length for frames.
        Since:
        5.1
      • upgrade

        public reactor.core.publisher.Mono<java.lang.Void> upgrade(ServerWebExchange exchange,
                                                                   WebSocketHandler handler,
                                                                   @Nullable
                                                                   java.lang.String subProtocol,
                                                                   java.util.function.Supplier<HandshakeInfo> handshakeInfoFactory)
        Description copied from interface: RequestUpgradeStrategy
        Upgrade to a WebSocket session and handle it with the given handler.
        Specified by:
        upgrade in interface RequestUpgradeStrategy
        Parameters:
        exchange - the current exchange
        handler - handler for the WebSocket session
        subProtocol - the selected sub-protocol got the handler
        handshakeInfoFactory - factory to create HandshakeInfo for the WebSocket session
        Returns:
        completion Mono<Void> to indicate the outcome of the WebSocket session handling.