Class NettyIdleStateKeepAliveHandler

  • All Implemented Interfaces:,,

    public class NettyIdleStateKeepAliveHandler
    A NettyIdleStateKeepAliveHandler listens for IdleStateEvents triggered by an IdleStateHandler. When invoked, the existence of a flag on the ChannelHandlerContext is determined. If this flag does not exist, then a keep-alive check if performed and the flag is set. If the does exist, then it is assumed that the peer failed the keep-alive check and the connection should be closed. The keep-alive check is implemented as an XMPP ping request. 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. As any inbound data will cause the flag to be reset, the connection will no longer be deemed 'idle'. Entities that do not respond to the IQ Ping stanzas can be considered dead, and their connection will be closed when the IdleStateHandler triggers the second idle event in a row. Note that whitespace pings that are sent by XMPP entities will also cause the connection idle count to be reset.
    Alex Gidman
    See Also:
    IdleStateEvent, IdleStateHandler
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface
    • Method Summary

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

        bind, close, connect, deregister, disconnect, flush, read, write
      • Methods inherited from class

        channelActive, channelInactive, channelRead, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught
      • Methods inherited from class

        ensureNotSharable, handlerAdded, handlerRemoved, isSharable
      • Methods inherited from interface

        handlerAdded, handlerRemoved
    • Constructor Detail

      • NettyIdleStateKeepAliveHandler

        public NettyIdleStateKeepAliveHandler​(boolean clientConnection)
    • Method Detail

      • userEventTriggered

        public void userEventTriggered​( 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
        userEventTriggered in class
        ctx - ChannelHandlerContext
        evt - Event caught, expect IdleStateEvent
        Exception - when attempting to deliver ping packet