Not a bug - this how heartbeats are sent
________________________________ From: Mei <meixiufe...@163.com> Sent: Thursday, October 26, 2017 2:55 PM To: dev@mina.apache.org; us...@mina.apache.org Subject: The heartbeat task of client not support keepalive function well,is it a bug? The heartbeat task of client not support keepalive function well,is it a bug? 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(); as the buffer of heartbeat set false, then the sendGlobalResponse will not reponse sshClient because of the wantReply is false .(see [AbstractConnectionService #globalRequest) 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.