通过ssh2、sftp协议连接基于Apache MINA SSHD的服务时,长时间不用连接会自动断开,我们来看一下默认断开时间和如何修改断开时间。
Disconnecting(ServerSessionImpl[{username}@/{ip}:{port}]): SSH2_DISCONNECT_PROTOCOL_ERROR - Detected IdleTimeout after 600028/600000 ms
<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-core</artifactId>
<version>2.8.0</version>
</dependency>
org.apache.sshd.core.CoreModuleProperties的IDLE_TIMEOUT
AUTH_TIMEOUT是顺便发现的参数
/**
* Key used to retrieve the value of the timeout after which it will close the connection if the other side has not
* been authenticated - in milliseconds.
*/
public static final Property<Duration> AUTH_TIMEOUT
= Property.duration("auth-timeout", Duration.ofMinutes(2));
/**
* Key used to retrieve the value of idle timeout after which it will close the connection - in milliseconds.
*/
public static final Property<Duration> IDLE_TIMEOUT
= Property.duration("idle-timeout", Duration.ofMinutes(10));
没有提供外部配置,可以通过将此类复制到项目代码中修改时间,启动时会先加载自定义的此类。
也可以提供其他影响类加载的方式修改此变量。
追踪代码的流程不说了,登录验证超时时间2分钟,连接空闲后断开的默认超时时间10分钟