You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "ruanwenjun (via GitHub)" <gi...@apache.org> on 2024/06/07 02:47:16 UTC
Re: [I] SSH Client Disconnects on Receiving Keepalive Requests [mina-sshd]
ruanwenjun commented on issue #482:
URL: https://github.com/apache/mina-sshd/issues/482#issuecomment-2153752493
@coderZoe @tomaswolf Hi, I meet a problem related to the ssh keepalive.
My task failed seems due to the ssh channel closed, I am not sure if this is due to the heartbeat miss.
```
exceptionCaught(ClientSessionImpl[cebwmapp@/10.227.23.69:16022])[state=Opened] IOException: Connection reset by peer
```
My code is look like below
```
SshClient sshClient = SshClient.setUpDefaultClient();
sshClient.start();
ClientSession session = sshClient.connect(
sshConnectionParam.getUsername(),
sshConnectionParam.getHost(),
sshConnectionParam.getPort()).verify(timeout).getSession();
String password = sshConnectionParam.getPassword();
if (StringUtils.isNotEmpty(password)) {
session.addPasswordIdentity(password);
}
String privateKey = sshConnectionParam.getPrivateKey();
if (StringUtils.isNotEmpty(privateKey)) {
KeyPairResourceLoader loader = SecurityUtils.getKeyPairResourceParser();
Collection<KeyPair> keyPairCollection = loader.loadKeyPairs(null, null, null, privateKey);
for (KeyPair keyPair : keyPairCollection) {
session.addPublicKeyIdentity(keyPair);
}
}
if (!session.auth().verify(Duration.ofSeconds(timeout)).isSuccess()) {
throw new RuntimeException("Session auth failed");
}
session.setSessionHeartbeat(SessionHeartbeatController.HeartbeatType.IGNORE,
Duration.ofSeconds(PropertyUtils.getInt("session-connection-heartbeat-interval", 5)));
return session;
```
Do I need to add KeepAliveHandler.INSTANCE in globalRequestHandlers to avoid this?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org