Class WebSocketControlFrameHandler
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler
MockServer performs the WebSocket handshake by hand via
WebSocketServerHandshaker.handshake(io.netty.channel.Channel, io.netty.handler.codec.http.FullHttpRequest), which installs only the frame encoder and
decoder — unlike Netty's WebSocketServerProtocolHandler, it contributes no control-frame
behaviour at all. Without this handler a mocked WebSocket therefore never answers a PING and
never echoes a CLOSE, so every keepalive-based client (browsers, OkHttp's pingInterval,
Java-WebSocket's connection-lost detector) eventually tears the connection down mid-test.
RFC 6455 §5.5.2 makes the Pong a MUST, and §5.5.1 requires the close echo.
Installed immediately after a successful handshake, ahead of
GraphQLSubscriptionHandler and BidirectionalWebSocketFrameHandler.
PING frames are answered and forwarded downstream, because
WebSocketFrameType.PING is an expressible matcher frame type —
swallowing the ping here would silently stop those matchers firing.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Constructor Summary
ConstructorsConstructorDescriptionWebSocketControlFrameHandler(io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker handshaker) -
Method Summary
Modifier and TypeMethodDescriptionvoidchannelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg) Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Constructor Details
-
WebSocketControlFrameHandler
public WebSocketControlFrameHandler(io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker handshaker)
-
-
Method Details
-
channelRead
- Specified by:
channelReadin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelReadin classio.netty.channel.ChannelInboundHandlerAdapter
-