coderZoe opened a new issue, #482: URL: https://github.com/apache/mina-sshd/issues/482
### Version group: 'org.apache.sshd',name: 'sshd-core',version: '2.12.0' ### Bug description After my SSH client receives the message `o.a.sshd.client.channel.ChannelShell - handleUnknownChannelRequest(ChannelShell[id=0, recipient=0]-ClientSessionImpl[admin@/10.252.146.106:61122]) Unknown channel request: keepal...@openssh.com[want-reply=true]`, it immediately disconnects from the server (it is possible that the server is the one terminating the connection). However, I have already set `KeepAliveHandler.INSTANCE` in the `GlobalRequestHandlers` when creating the client. Debugging the code shows that it does not enter the `KeepAliveHandler#process()` method, which seems to indicate that the setting of `GlobalRequestHandlers` has no effect. ### Actual behavior After my SSH client receives the message `o.a.sshd.client.channel.ChannelShell - handleUnknownChannelRequest(ChannelShell[id=0, recipient=0]-ClientSessionImpl[admin@/10.252.146.106:61122]) Unknown channel request: keepal...@openssh.com[want-reply=true]`, it immediately disconnects from the server (it is possible that the server is the one terminating the connection). ### Expected behavior Why is this happening? Is it because the server sent a keepalive packet and I did not respond, causing the server to terminate the connection? I do not wish to disconnect and reconnect every so often; I want to maintain a long connection. If it is due to not responding to the server's keepalive packets, what should I do to keep the connection alive at all times? ### Relevant log output ```Shell here is the log: [WARN ] 10:16:53.178 [sshd-SshClient[72dd8b0]-nio2-thread-1] [ ] o.a.sshd.client.channel.ChannelShell - handleUnknownChannelRequest(ChannelShell[id=0, recipient=0]-ClientSessionImpl[admin@/10.252.146.106:61122]) Unknown channel request: keepal...@openssh.com[want-reply=true] ```log org.apache.sshd.common.SshException: IoReadFutureImpl[ChannelAsyncInputStream[ChannelShell[id=0, recipient=0]-ClientSessionImpl[admin@/10.252.146.106:61122]]]: Failed (EOFException) to execute: Closed at org.apache.sshd.common.future.AbstractSshFuture.lambda$verifyResult$2(AbstractSshFuture.java:146) at org.apache.sshd.common.future.AbstractSshFuture.formatExceptionMessage(AbstractSshFuture.java:206) at org.apache.sshd.common.future.AbstractSshFuture.verifyResult(AbstractSshFuture.java:145) at org.apache.sshd.common.channel.ChannelAsyncInputStream$IoReadFutureImpl.verify(ChannelAsyncInputStream.java:173) at org.apache.sshd.common.channel.ChannelAsyncInputStream$IoReadFutureImpl.verify(ChannelAsyncInputStream.java:156) at org.apache.sshd.common.future.VerifiableFuture.verify(VerifiableFuture.java:74) at com.uca.network.v2.communication.core.sender.session.BaseSshSessionSender$ChannelResponseListener.operationComplete(BaseSshSessionSender.java:290) at com.uca.network.v2.communication.core.sender.session.BaseSshSessionSender$ChannelResponseListener.operationComplete(BaseSshSessionSender.java:268) at org.apache.sshd.common.future.AbstractSshFuture.lambda$notifyListener$3(AbstractSshFuture.java:178) at org.apache.sshd.common.util.threads.ThreadUtils.runAsInternal(ThreadUtils.java:64) at org.apache.sshd.common.future.AbstractSshFuture.notifyListener(AbstractSshFuture.java:177) at org.apache.sshd.common.future.DefaultSshFuture.notifyListeners(DefaultSshFuture.java:257) at org.apache.sshd.common.future.DefaultSshFuture.setValue(DefaultSshFuture.java:160) at org.apache.sshd.common.channel.ChannelAsyncInputStream.preClose(ChannelAsyncInputStream.java:98) at org.apache.sshd.common.util.closeable.AbstractCloseable.close(AbstractCloseable.java:109) at org.apache.sshd.common.util.closeable.ParallelCloseable.doClose(ParallelCloseable.java:65) at org.apache.sshd.common.util.closeable.SimpleCloseable.close(SimpleCloseable.java:63) at org.apache.sshd.common.util.closeable.SequentialCloseable$1.operationComplete(SequentialCloseable.java:56) at org.apache.sshd.common.util.closeable.SequentialCloseable$1.operationComplete(SequentialCloseable.java:45) at org.apache.sshd.common.future.AbstractSshFuture.lambda$notifyListener$3(AbstractSshFuture.java:178) at org.apache.sshd.common.util.threads.ThreadUtils.runAsInternal(ThreadUtils.java:64) at org.apache.sshd.common.future.AbstractSshFuture.notifyListener(AbstractSshFuture.java:177) at org.apache.sshd.common.future.DefaultSshFuture.addListener(DefaultSshFuture.java:214) at org.apache.sshd.common.util.closeable.SequentialCloseable$1.operationComplete(SequentialCloseable.java:57) at org.apache.sshd.common.util.closeable.SequentialCloseable$1.operationComplete(SequentialCloseable.java:45) at org.apache.sshd.common.future.AbstractSshFuture.lambda$notifyListener$3(AbstractSshFuture.java:178) at org.apache.sshd.common.util.threads.ThreadUtils.runAsInternal(ThreadUtils.java:64) at org.apache.sshd.common.future.AbstractSshFuture.notifyListener(AbstractSshFuture.java:177) at org.apache.sshd.common.future.DefaultSshFuture.addListener(DefaultSshFuture.java:214) at org.apache.sshd.common.util.closeable.SequentialCloseable$1.operationComplete(SequentialCloseable.java:57) at org.apache.sshd.common.util.closeable.SequentialCloseable$1.operationComplete(SequentialCloseable.java:45) at org.apache.sshd.common.util.closeable.SequentialCloseable.doClose(SequentialCloseable.java:69) at org.apache.sshd.common.util.closeable.SimpleCloseable.close(SimpleCloseable.java:63) at org.apache.sshd.common.util.closeable.SequentialCloseable$1.operationComplete(SequentialCloseable.java:56) at org.apache.sshd.common.util.closeable.SequentialCloseable$1.operationComplete(SequentialCloseable.java:45) at org.apache.sshd.common.util.closeable.SequentialCloseable.doClose(SequentialCloseable.java:69) at org.apache.sshd.common.util.closeable.SimpleCloseable.close(SimpleCloseable.java:63) at org.apache.sshd.common.util.closeable.AbstractInnerCloseable.doCloseGracefully(AbstractInnerCloseable.java:41) at org.apache.sshd.common.util.closeable.AbstractCloseable.close(AbstractCloseable.java:110) at org.apache.sshd.common.channel.AbstractChannel.handleClose(AbstractChannel.java:578) at org.apache.sshd.common.session.helpers.AbstractConnectionService.channelClose(AbstractConnectionService.java:644) at org.apache.sshd.common.session.helpers.AbstractConnectionService.process(AbstractConnectionService.java:483) at org.apache.sshd.common.session.helpers.CurrentService.process(CurrentService.java:109) at org.apache.sshd.common.session.helpers.AbstractSession.doHandleMessage(AbstractSession.java:624) at org.apache.sshd.common.session.helpers.AbstractSession.lambda$handleMessage$0(AbstractSession.java:545) at org.apache.sshd.common.util.threads.ThreadUtils.runAsInternal(ThreadUtils.java:68) at org.apache.sshd.common.session.helpers.AbstractSession.handleMessage(AbstractSession.java:544) at org.apache.sshd.common.session.helpers.AbstractSession.decode(AbstractSession.java:1688) at org.apache.sshd.common.session.helpers.AbstractSession.messageReceived(AbstractSession.java:505) at org.apache.sshd.common.session.helpers.AbstractSessionIoHandler.messageReceived(AbstractSessionIoHandler.java:64) at org.apache.sshd.common.io.nio2.Nio2Session.handleReadCycleCompletion(Nio2Session.java:409) at org.apache.sshd.common.io.nio2.Nio2Session$1.onCompleted(Nio2Session.java:382) at org.apache.sshd.common.io.nio2.Nio2Session$1.onCompleted(Nio2Session.java:377) at org.apache.sshd.common.io.nio2.Nio2CompletionHandler.lambda$completed$0(Nio2CompletionHandler.java:38) at java.security.AccessController.doPrivileged(Native Method) at org.apache.sshd.common.io.nio2.Nio2CompletionHandler.completed(Nio2CompletionHandler.java:37) at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126) at sun.nio.ch.Invoker$2.run(Invoker.java:218) at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:750) Caused by: java.io.EOFException: Closed ... 49 common frames omitted ``` Here is the code I used to set up the client: ```java this.client = SshClient.setUpDefaultClient(); this.client.start(); this.client.setGlobalRequestHandlers(Arrays.asList(KeepAliveHandler.INSTANCE, NoMoreSessionsHandler.INSTANCE)); ConnectFuture connectFuture = client.connect(metaData.getUserName(), metaData.getIp(), metaData.getPort()) .verify(metaData.getConnectTimeout()); if (connectFuture.isConnected()) { this.session = connectFuture.getSession(); } else { throw new ConnectException(connectFuture.getException().getMessage()); } this.session.addPasswordIdentity(metaData.getPassword()); AuthFuture authFuture = this.session.auth().verify(metaData.getAuthTimeout()); if (authFuture.isSuccess()) { this.status = SenderStatus.CONNECTING; } else { throw new AuthException("Auth Fail:" + authFuture.getException().getMessage()); } this.channel = createChannel(); ``` ```java public ClientChannel createChannel() throws Exception { ClientChannel channel = this.session.createChannel(ClientChannel.CHANNEL_SHELL); channel.setStreaming(ClientChannel.Streaming.Async); channel.open().verify(); channel.getAsyncOut().read(new ByteArrayBuffer(BUFFER_PIPE_SIZE)).addListener(new ChannelResponseListener(this)); return channel; } ``` ``` ### Other information _No response_ -- 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-unsubscr...@mina.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org For additional commands, e-mail: dev-h...@mina.apache.org