Apache SSHD服务端:ssh2、sftp 登录验证超时时间、连接断开超时时间

通过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分钟

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值