private void close(Session session) {
    if (session != null && session.getSocketChannel() != null) {
      try {
        if (session.getSocketChannel().keyFor(selector) != null) {
          session.getSocketChannel().keyFor(selector).cancel();
        }
        if (session.getSocketChannel().isConnected()) {
          session.getSocketChannel().close();
        }
      } catch (IOException e) {
        logger.error("", e);
      }
      session.setSocketChannel(null);
      timeoutSessionSet.remove(session);
      session.close();
      session.setIdle(true);
    }

  }