@Override
    public void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
        Connection connection = ctx.channel().attr(CONNECTION).get();
        if (connection != null) {
            connection.close(); // clean up resources (connection and session) when channel is unregistered.
        }
        super.channelUnregistered(ctx);
    }
Returns the time that a connection can be idle before being closed.

@return the time a connection can be idle.
xmppserver/src/main/java/org/jivesoftware/openfire/nio/NettyConnectionHandler.java