Class ReactorNettyRequestUpgradeStrategy

    • Constructor Detail

      • ReactorNettyRequestUpgradeStrategy

        public ReactorNettyRequestUpgradeStrategy​(Supplier<reactor.netty.http.server.WebsocketServerSpec.Builder> builderSupplier)
        Create an instance with a pre-configured WebsocketServerSpec.Builder to use for WebSocket upgrades.
        Since:
        5.2.6
    • Method Detail

      • getWebsocketServerSpec

        public reactor.netty.http.server.WebsocketServerSpec getWebsocketServerSpec()
        Build an instance of WebsocketServerSpec that reflects the current configuration. This can be used to check the configured parameters except for sub-protocols which depend on the WebSocketHandler that is used for a given upgrade.
        Since:
        5.2.6
      • setMaxFramePayloadLength

        @Deprecated
        public void setMaxFramePayloadLength​(Integer maxFramePayloadLength)
        Deprecated.
        as of 5.2.6 in favor of providing a supplier of WebsocketServerSpec.Builder wiht a constructor argument.
        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
      • setHandlePing

        @Deprecated
        public void setHandlePing​(boolean handlePing)
        Deprecated.
        as of 5.2.6 in favor of providing a supplier of WebsocketServerSpec.Builder wiht a constructor argument.
        Configure whether to let ping frames through to be handled by the WebSocketHandler given to the upgrade method. By default, Reactor Netty automatically replies with pong frames in response to pings. This is useful in a proxy for allowing ping and pong frames through.

        By default this is set to false in which case ping frames are handled automatically by Reactor Netty. If set to true, ping frames will be passed through to the WebSocketHandler.

        Parameters:
        handlePing - whether to let Ping frames through for handling
        Since:
        5.2.4
      • upgrade

        public reactor.core.publisher.Mono<Voidupgrade​(ServerWebExchange exchange,
                                                         WebSocketHandler handler,
                                                         @Nullable
                                                         String subProtocol,
                                                         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.