bullettrain1433
V2EX  ›  Java

弱弱问一下 Spring Boot2 里 websocket 问题

  •  
  •   bullettrain1433 · Oct 30, 2018 · 2346 views
    This topic created in 2826 days ago, the information mentioned may be changed or developed.
    使用了注入的生成 websocket 服务,连接关闭都正常
    问题来了,客户端连接时候,突然设备断网,服务端无法检测到断线,session 记录一直保存,找了一圈没找到能 Spring Boot2 里配置 websocket 的超时时间的地方,

    请教下各位 v 友
    4 replies    2018-10-30 23:59:42 +08:00
    xyjincan
        1
    xyjincan  
       Oct 30, 2018
    加一个最后服务时间呗,定时遍历检查,删除垃圾连接
    bullettrain1433
        2
    bullettrain1433  
    OP
       Oct 30, 2018
    @xyjincan 这样服务端压力比较大,相当于做了心跳了
    KevinBlandy
        3
    KevinBlandy  
       Oct 30, 2018
    咋可能没呢。每个 Session 都有一个 Api。设置超时时间的。

    this.session.setMaxIdleTimeout(-1);
    bullettrain1433
        4
    bullettrain1433  
    OP
       Oct 30, 2018 via iPhone
    @KevinBlandy 谢谢指导,我这再求教一点比如我设置六秒,六秒客户端没有跟服务端 websocket 交互数据直接断开吗?如果是这样好像也不符合我现在需求
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5989 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 02:26 · PVG 10:26 · LAX 19:26 · JFK 22:26
    ♥ Do have faith in what you're doing.