mirror of
https://gitee.com/IrisVega/frp.git
synced 2024-11-01 22:31:29 +08:00
fix heartbeat error
This commit is contained in:
parent
58d0d41501
commit
30aeaf968e
@ -218,7 +218,7 @@ func (ctl *Control) reader() {
|
|||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
ctl.Warn("read error: %v", err)
|
ctl.Warn("read error: %v", err)
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ctl.readCh <- m
|
ctl.readCh <- m
|
||||||
@ -262,10 +262,13 @@ func (ctl *Control) manager() {
|
|||||||
select {
|
select {
|
||||||
case <-hbSend.C:
|
case <-hbSend.C:
|
||||||
// send heartbeat to server
|
// send heartbeat to server
|
||||||
|
ctl.Debug("send heartbeat to server")
|
||||||
ctl.sendCh <- &msg.Ping{}
|
ctl.sendCh <- &msg.Ping{}
|
||||||
case <-hbCheck.C:
|
case <-hbCheck.C:
|
||||||
if time.Since(ctl.lastPong) > time.Duration(config.ClientCommonCfg.HeartBeatTimeout)*time.Second {
|
if time.Since(ctl.lastPong) > time.Duration(config.ClientCommonCfg.HeartBeatTimeout)*time.Second {
|
||||||
ctl.Warn("heartbeat timeout")
|
ctl.Warn("heartbeat timeout")
|
||||||
|
// let reader() stop
|
||||||
|
ctl.conn.Close()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case rawMsg, ok := <-ctl.readCh:
|
case rawMsg, ok := <-ctl.readCh:
|
||||||
@ -302,6 +305,7 @@ func (ctl *Control) manager() {
|
|||||||
ctl.Info("[%s] start proxy success", m.ProxyName)
|
ctl.Info("[%s] start proxy success", m.ProxyName)
|
||||||
case *msg.Pong:
|
case *msg.Pong:
|
||||||
ctl.lastPong = time.Now()
|
ctl.lastPong = time.Now()
|
||||||
|
ctl.Debug("receive heartbeat from server")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -318,6 +318,7 @@ func (ctl *Control) manager() {
|
|||||||
ctl.sendCh <- resp
|
ctl.sendCh <- resp
|
||||||
case *msg.Ping:
|
case *msg.Ping:
|
||||||
ctl.lastPing = time.Now()
|
ctl.lastPing = time.Now()
|
||||||
|
ctl.conn.Debug("receive heartbeat")
|
||||||
ctl.sendCh <- &msg.Pong{}
|
ctl.sendCh <- &msg.Pong{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user