[
https://issues.apache.org/jira/browse/SSHD-781?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16223284#comment-16223284
]
MayDay commented on SSHD-781:
-----------------------------
[~lgoldstein], Thanks for answer me.
1、As you say, {color:#654982}to avoid that either increase this timeout or do
something that you know will trigger some (valid) server response and thus
reset the read timeout.{color}.{color:#205081} run some periodic "harmless"
command - e.g., echo "hello there I am still alive" - before the read timeout
expires{color}.
The heartbeat of sshClient is the periodic sending message. Why not use this
and make sshServer reponse to the heartbeat,just make the
[ClientConnectService#sendHeartbeat|https://github.com/apache/mina-sshd/blob/093a979b6b56b115045d567e7ae9529f99ce1e9f/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java]
{code:java}
buf.putBoolean(true);
{code}
So that the sshServer will reponse the heartbeat and reset the read timeout.
Or can I fixed it true like above to realize that the client side can Identify
connection anomalies in time(which function I want sshClient have, in my
scene, I'm more concerned about client connection status changes in time when
Client and server network unreachable
).
2、 As the firse comment you add {color:#205081}"Send a keep-alive message with
wantReply=true may cause SSH_MSG_FAILURE-s to be sent since the peer does not
"understand" these messages"{color}
, the sshServer will reponse a SSH_MSG_REQUEST_FAILURE, What's the influence?I
have see that the related code [AbstractSession #
requestFailure|https://github.com/apache/mina-sshd/blob/master/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java]
> The heartbeat task of client not support keepalive function well
> ----------------------------------------------------------------
>
> Key: SSHD-781
> URL: https://issues.apache.org/jira/browse/SSHD-781
> Project: MINA SSHD
> Issue Type: Question
> Affects Versions: 1.4.0, 1.6.0
> Environment: Any environment
> Reporter: MayDay
> Assignee: Guillaume Nodet
> Labels: test
> Fix For: 1.7.0
>
>
>
> The heartbeat request of sshClient is a SSH_MSG_GLOBAL_REQUEST, but
> the default buffer of heartbeat set false (see
> [ClientConnectService#sendHeartbeat|https://github.com/apache/mina-sshd/blob/693fa5d90f54676de6655954046a8a4f5d09728a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java])
> {code:java}
> buf.putBoolean(false);
> {code}
> The sshServer reponse the heartbeat by the
> [KeepAliveHandler|https://github.com/apache/mina-sshd/blob/693fa5d90f54676de6655954046a8a4f5d09728a/sshd-core/src/main/java/org/apache/sshd/server/global/KeepAliveHandler.java],
> then [AbstractConnectionService
> #sendGlobalResponse|https://github.com/apache/mina-sshd/blob/693fa5d90f54676de6655954046a8a4f5d09728a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java].
> {code:java}
> boolean wantReply = buffer.getBoolean();
> {code}
> but if the buffer of heartbeat set false, then the sendGlobalResponse
> will not reponse sshClient {color:#205081}because of the wantReply is
> false{color} .(see [AbstractConnectionService
> #globalRequest|https://github.com/apache/mina-sshd/blob/693fa5d90f54676de6655954046a8a4f5d09728a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java])
> {code:java}
> if (RequestHandler.Result.Replied.equals(result) || (!wantReply)) {
> return new AbstractIoWriteFuture(req, null) {
> {
> setValue(Boolean.TRUE);
> }
> };
> }
> {code}
> 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
> {color:#8eb021}InterruptedByTimeoutException{color},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|https://github.com/apache/mina-sshd/blob/693fa5d90f54676de6655954046a8a4f5d09728a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java]
> {code:java}
> service.scheduleAtFixedRate(this::sendHeartBeat, interval, interval,
> TimeUnit.MILLISECONDS);
> {code}
> 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.
>
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)