[ https://issues.apache.org/jira/browse/SSHD-891?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16770055#comment-16770055 ]
Anudeep commented on SSHD-891: ------------------------------ Hi [~lgoldstein], We have uplifted sshd-core version from 0.13.0 to 2.1.0. But with 2.1.0 we see many impacts one such is client session is getting closed abruptly after few minutes Please find below logs {code:java} [id=0, recipient=43]-ServerSessionImpl[administrator@/141.137.237.205:58516]) by 4 down to 191244 2019-02-16 06:34:10,697 DEBUG [org.apache.sshd.common.io.nio2.Nio2Session] (EJB default - 44) writePacket(Nio2Session[local=/10.247. 246.100:8345, remote=/141.137.237.205:58516]) Writing 68 bytes 2019-02-16 06:34:10,697 DEBUG [org.apache.sshd.common.io.nio2.Nio2Session] (sshd-SshServer[5c704bd8]-nio2-thread-3) handleCompletedWriteCycle(Nio2Session[local=/10.247.246.100:8345, remote=/141.137.237.205:58516]) finished writing len=68 2019-02-16 06:34:17,050 DEBUG [org.apache.sshd.common.io.nio2.Nio2Session] (sshd-SshServer[5c704bd8]-nio2-thread-1) exceptionCaught(Nio2Session[local=/10.247.246.100:8345, remote=/141.137.237.205:58516]) caught InterruptedByTimeoutException[null] - calling handler 2019-02-16 06:34:17,050 WARN [org.apache.sshd.server.session.ServerSessionImpl] (sshd-SshServer[5c704bd8]-nio2-thread-1) exceptionCaught(ServerSessionImpl[administrator@/141.137.237.205:58516])[state=Opened] InterruptedByTimeoutException: null 2019-02-16 06:34:17,050 DEBUG [org.apache.sshd.server.session.ServerSessionImpl] (sshd-SshServer[5c704bd8]-nio2-thread-1) exceptionCaught(ServerSessionImpl[administrator@/141.137.237.205:58516])[state=Opened] details: java.nio.channels.InterruptedByTimeoutException at sun.nio.ch.UnixAsynchronousSocketChannelImpl$1.run(UnixAsynchronousSocketChannelImpl.java:456) [rt.jar:1.8.0_172] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [rt.jar:1.8.0_172] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_172] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [rt.jar:1.8.0_172] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [rt.jar:1.8.0_172] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [rt.jar:1.8.0_172] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [rt.jar:1.8.0_172] at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_172] 2019-02-16 06:34:17,053 DEBUG [org.apache.sshd.common.session.helpers.SessionTimeoutListener] (sshd-SshServer[5c704bd8]-nio2-thread-1) sessionException(ServerSessionImpl[administrator@/141.137.237.205:58516]) InterruptedByTimeoutException: null 2019-02-16 06:34:17,053 DEBUG [org.apache.sshd.common.session.helpers.SessionTimeoutListener] (sshd-SshServer[5c704bd8]-nio2-thread-1) sessionClosed(ServerSessionImpl[administrator@/141.137.237.205:58516]) un-tracked 2019-02-16 06:34:17,053 DEBUG [org.apache.sshd.server.session.ServerSessionImpl] (sshd-SshServer[5c704bd8]-nio2-thread-1) close(ServerSessionImpl[administrator@/141.137.237.205:58516]) Closing immediately 2019-02-16 06:34:17,053 DEBUG [org.apache.sshd.server.session.ServerConnectionService] (sshd-SshServer[5c704bd8]-nio2-thread-1) close(ServerConnectionService[ServerSessionImpl[administrator@/141.137.237.205:58516]]) Closing immediately 2019-02-16 06:34:17,054 DEBUG [org.apache.sshd.server.channel.ChannelSession] (sshd-SshServer[5c704bd8]-nio2-thread-1) close(ChannelSession[id=0, recipient=43]-ServerSessionImpl[administrator@/141.137.237.205:58516]) Closing immediately 2019-02-16 06:34:17,054 DEBUG [org.apache.sshd.server.channel.ChannelSession] (sshd-SshServer[5c704bd8]-nio2-thread-1) close(Channel: {code} And with respect to setting the state of sshd we are not able to access the state variable from ssh-server package as state varaible is made protected in ssh-common package {code} /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.sshd.common.util.closeable; import java.util.concurrent.atomic.AtomicReference; import org.apache.sshd.common.future.CloseFuture; import org.apache.sshd.common.future.DefaultCloseFuture; import org.apache.sshd.common.future.SshFuture; import org.apache.sshd.common.future.SshFutureListener; /** * Provides some default implementations * * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a> */ public abstract class AbstractCloseable extends IoBaseCloseable { public enum State { Opened, Graceful, Immediate, Closed } /** * Lock object for this session state */ protected final Object lock = new Object(); /** * State of this object */ protected final AtomicReference<AbstractCloseable.State> state = new AtomicReference<>(State.Opened); /** * A future that will be set 'closed' when the object is actually closed */ protected final CloseFuture closeFuture; protected AbstractCloseable() { this(""); } protected AbstractCloseable(String discriminator) { super(discriminator); closeFuture = new DefaultCloseFuture(discriminator, lock); } @Override public void addCloseFutureListener(SshFutureListener<CloseFuture> listener) { closeFuture.addListener(listener); } @Override public void removeCloseFutureListener(SshFutureListener<CloseFuture> listener) { closeFuture.removeListener(listener); } @Override public final CloseFuture close(boolean immediately) { boolean debugEnabled = log.isDebugEnabled(); if (immediately) { if (state.compareAndSet(State.Opened, State.Immediate) || state.compareAndSet(State.Graceful, State.Immediate)) { if (debugEnabled) { log.debug("close({}) Closing immediately", this); } preClose(); doCloseImmediately(); if (debugEnabled) { log.debug("close({})[Immediately] closed", this); } } else { if (debugEnabled) { log.debug("close({})[Immediately] state already {}", this, state.get()); } } } else { if (state.compareAndSet(State.Opened, State.Graceful)) { if (debugEnabled) { log.debug("close({}) Closing gracefully", this); } preClose(); SshFuture<CloseFuture> grace = doCloseGracefully(); if (grace != null) { grace.addListener(future -> { if (state.compareAndSet(State.Graceful, State.Immediate)) { doCloseImmediately(); if (debugEnabled) { log.debug("close({}][Graceful] - operationComplete() closed", AbstractCloseable.this); } } }); } else { if (state.compareAndSet(State.Graceful, State.Immediate)) { doCloseImmediately(); if (debugEnabled) { log.debug("close({})[Graceful] closed", this); } } } } else { if (debugEnabled) { log.debug("close({})[Graceful] state already {}", this, state.get()); } } } return closeFuture; } @Override public final boolean isClosed() { return state.get() == State.Closed; } @Override public final boolean isClosing() { return state.get() != State.Opened; } /** * preClose is guaranteed to be called before doCloseGracefully or doCloseImmediately. * When preClose() is called, isClosing() == true */ protected void preClose() { // nothing } protected CloseFuture doCloseGracefully() { return null; } /** * <P>doCloseImmediately is called once and only once * with state == Immediate</P> * * <P>Overriding methods should always call the base implementation. * It may be called concurrently while preClose() or doCloseGracefully is executing</P> */ protected void doCloseImmediately() { closeFuture.setClosed(); state.set(State.Closed); } protected Builder builder() { return new Builder(lock); } } {code} {code} public static void setStateOnInit(final SshServer sshd) { // Opened, Graceful, Immediate, Closed sshd.state.set(State.Opened); } In the above code we are not able to set state {code} Please let us know if you need more inputs. Regards, Anudeep > SSh connections gets closed for every one hour with 0.13.0 version > ------------------------------------------------------------------ > > Key: SSHD-891 > URL: https://issues.apache.org/jira/browse/SSHD-891 > Project: MINA SSHD > Issue Type: Bug > Reporter: Anudeep > Assignee: Goldstein Lyor > Priority: Blocker > > SSH connections are getting closed for every one hours after 10 mins of idle > time even though there are incoming pacets data is not being wriiten to > client for every one hour and is being idle(10 mins which is default timeout > of ssh session). -- This message was sent by Atlassian JIRA (v7.6.3#76005)