code: @Override
    public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
      if (evt instanceof IdleStateEvent) {
        IdleStateEvent e = (IdleStateEvent) evt;
        if (e.state() == IdleState.READER_IDLE) {
          LOGGER.warn("Closing dead connection.");
          ctx.close();
          return;
        }
      }
  
      super.userEventTriggered(ctx, evt);
    }
docs: Close dead connection in response to idle event from IdleStateHandler.