Class InboundConnectionIdleHandler

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
io.netty.handler.timeout.IdleStateHandler
org.mockserver.netty.connection.InboundConnectionIdleHandler
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler, io.netty.channel.ChannelOutboundHandler

public final class InboundConnectionIdleHandler extends io.netty.handler.timeout.IdleStateHandler
Closes an inbound connection that has read and written nothing for inboundConnectionIdleTimeoutMillis and has nothing in progress (see InboundConnectionActivity.isBusy(io.netty.channel.Channel)). A busy connection is left alone and checked again after another full period of silence.

Installed first in the pipeline when the connection is accepted. TLS and SOCKS handlers added later by protocol detection sit in front of it, so it observes decrypted application traffic rather than raw socket bytes. A TLS handshake's records therefore never reach it: the handshake is covered by the busy check while it runs, and its completion restarts the idle period, so the client has a whole period to send its first request. The idle event is consumed here rather than fired down the pipeline, so no other handler that reacts to IdleStateEvent can act on it.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

    io.netty.channel.ChannelHandler.Sharable
  • Constructor Summary

    Constructors
    Constructor
    Description
    InboundConnectionIdleHandler(long idleTimeoutMillis, org.mockserver.logging.MockServerLogger mockServerLogger)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    channelIdle(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.timeout.IdleStateEvent evt)
     
    void
    handlerAdded(io.netty.channel.ChannelHandlerContext ctx)
     
    void
    userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt)
     

    Methods inherited from class io.netty.handler.timeout.IdleStateHandler

    channelActive, channelInactive, channelRead, channelReadComplete, channelRegistered, getAllIdleTimeInMillis, getReaderIdleTimeInMillis, getWriterIdleTimeInMillis, handlerRemoved, newIdleStateEvent, resetReadTimeout, resetWriteTimeout, write

    Methods inherited from class io.netty.channel.ChannelDuplexHandler

    bind, close, connect, deregister, disconnect, flush, read

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelUnregistered, channelWritabilityChanged, exceptionCaught

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, isSharable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • InboundConnectionIdleHandler

      public InboundConnectionIdleHandler(long idleTimeoutMillis, org.mockserver.logging.MockServerLogger mockServerLogger)
  • Method Details

    • handlerAdded

      public void handlerAdded(io.netty.channel.ChannelHandlerContext ctx) throws Exception
      Specified by:
      handlerAdded in interface io.netty.channel.ChannelHandler
      Overrides:
      handlerAdded in class io.netty.handler.timeout.IdleStateHandler
      Throws:
      Exception
    • userEventTriggered

      public void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt) throws Exception
      Specified by:
      userEventTriggered in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      userEventTriggered in class io.netty.channel.ChannelInboundHandlerAdapter
      Throws:
      Exception
    • channelIdle

      protected void channelIdle(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.timeout.IdleStateEvent evt)
      Overrides:
      channelIdle in class io.netty.handler.timeout.IdleStateHandler