Class NettyIdleStateKeepAliveHandler

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler, io.netty.channel.ChannelOutboundHandler

    public class NettyIdleStateKeepAliveHandler
    extends io.netty.channel.ChannelDuplexHandler
    A NettyIdleStateKeepAliveHandler listens for IdleStateEvents triggered by an IdleStateHandler. The readerIdleTimeSeconds in IdleStateHandler should be set to a value higher than writerIdleTimeSeconds (typically double), else the connection will always be closed. XMPP entities must respond with either an IQ result or an IQ error (feature-unavailable) stanza upon receiving the XMPP ping stanza. Both responses will be received by Openfire and will cause the connection idle count to be reset. Entities that do not respond to the IQ Ping stanzas can be considered dead, and their connection will be closed when the IdleStateHandler triggers an idle read state. Note that whitespace pings that are sent by XMPP entities will also cause the connection idle count to be reset.
    Author:
    Alex Gidman
    See Also:
    IdleStateEvent, IdleStateHandler
    • Nested Class Summary

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

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void userEventTriggered​(io.netty.channel.ChannelHandlerContext ctx, Object evt)
      Processes IdleStateEvents triggered by an IdleStateHandler.
      • Methods inherited from class io.netty.channel.ChannelDuplexHandler

        bind, close, connect, deregister, disconnect, flush, read, write
      • Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

        channelActive, channelInactive, channelRead, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught
      • Methods inherited from class io.netty.channel.ChannelHandlerAdapter

        ensureNotSharable, handlerAdded, handlerRemoved, isSharable
      • Methods inherited from interface io.netty.channel.ChannelHandler

        handlerAdded, handlerRemoved
    • Constructor Detail

      • NettyIdleStateKeepAliveHandler

        public NettyIdleStateKeepAliveHandler​(boolean clientConnection)
    • Method Detail

      • userEventTriggered

        public void userEventTriggered​(io.netty.channel.ChannelHandlerContext ctx,
                                       Object evt)
                                throws Exception
        Processes IdleStateEvents triggered by an IdleStateHandler. If the IdleStateEvent is an idle read state, the Netty channel is closed. If the IdleStateEvent is an idle write state, an XMPP ping request is sent to the remote entity.
        Specified by:
        userEventTriggered in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        userEventTriggered in class io.netty.channel.ChannelInboundHandlerAdapter
        Parameters:
        ctx - ChannelHandlerContext
        evt - Event caught, expect IdleStateEvent
        Throws:
        Exception - when attempting to deliver ping packet