mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-01 23:16:23 -05:00
Bettering ping method
This commit is contained in:
parent
e382eaa59f
commit
0a49628555
@ -183,19 +183,18 @@ func (ws *wsconn) pingPong() {
|
||||
ws.wlock.Lock()
|
||||
ws.wsc.WriteMessage(websocket.PingMessage, nil)
|
||||
ws.wlock.Unlock()
|
||||
tick := time.NewTicker(time.Second * 30)
|
||||
tick := time.After(time.Second * 3)
|
||||
|
||||
select {
|
||||
case <-pongRcv:
|
||||
break
|
||||
case <-tick.C:
|
||||
case <-tick:
|
||||
if !ws.connClosing {
|
||||
log.Debug("WS:Closing as ping is not responded~" + ws.wsc.UnderlyingConn().LocalAddr().String() + "-" + ws.wsc.UnderlyingConn().RemoteAddr().String())
|
||||
}
|
||||
ws.Close()
|
||||
}
|
||||
<-tick.C
|
||||
tick.Stop()
|
||||
<-time.After(time.Second * 27)
|
||||
}
|
||||
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user