Uploaded image for project: 'MINA SSHD'
  1. MINA SSHD
  2. SSHD-781

The heartbeat task of client not support keepalive function well

    XMLWordPrintableJSON

Details

    • Question
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.4.0, 1.6.0
    • 1.7.0
    • Any environment

    Description

      The heartbeat request of sshClient is a SSH_MSG_GLOBAL_REQUEST, but the default buffer of heartbeat set false (see ClientConnectService#sendHeartbeat)

      buf.putBoolean(false);
      

      The sshServer reponse the heartbeat by the KeepAliveHandler, then AbstractConnectionService #sendGlobalResponse.

       boolean wantReply = buffer.getBoolean();
      

      but if the buffer of heartbeat set false, then the sendGlobalResponse will not reponse sshClient because of the wantReply is false .(see AbstractConnectionService #globalRequest)

      if (RequestHandler.Result.Replied.equals(result) || (!wantReply)) {
                  return new AbstractIoWriteFuture(req, null) {
                      {
                          setValue(Boolean.TRUE);
                      }
                  };
      }
      

      1 、Is it a Bug(set the heartbeat buffer false default)? how the sshClient know the server is available when the server don't response.
      I have test it whth create a client with params (
      HEARTBEAT_INTERAL = 60
      IDLE_TIMEOUT = 300
      NIO_READ_TIMEOUT = 315)and a server, and the client will close seesion after the NIO_READ_TIMEOUT.

      2、If the client reach the NIO_READ_TIMEOUT, then thows a InterruptedByTimeoutException,and close the session.But the task of heratbeat not stoped, it will continue to run even though it will not send packet.See the
      ClientConnectionService #startHeartBeat

      service.scheduleAtFixedRate(this::sendHeartBeat, interval, interval, TimeUnit.MILLISECONDS);
      

      if the sshClient reopen a new session and close it many times,the number of invalid scheduling heartbeat task will become very large, it's not equitable.

      Attachments

        Issue Links

          Activity

            People

              gnodet Guillaume Nodet
              MayDay MayDay
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: