[GH-ISSUE #2192] 客户端向服务端(frpc->frps)发送心跳服务如果在某个时间点上出现网络抖动,不应该直接关闭服务吧 #1749

Closed
opened 2026-05-05 13:07:26 -06:00 by gitea-mirror · 2 comments
Owner

Originally created by @Owen-Zhang on GitHub (Jan 16, 2021).
Original GitHub issue: https://github.com/fatedier/frp/issues/2192

首先作者写的这个工具很好,我们公司也在用,最近有空进来学习一下源码

客户端向服务端(frpc->frps)发送心跳服务,如果在某个时间点上出现网络抖动,不应该直接关闭服务吧
control.go -> msgHandler() ->

for {
select {
  //...
  case <-hbCheck.C:
			if time.Since(ctl.lastPong) > time.Duration(ctl.clientCfg.HeartbeatTimeout)*time.Second {
				xl.Warn("heartbeat timeout")
				// let reader() stop
				ctl.conn.Close()
				return  //这里直接返回,并关闭了conn
			}
}
}

在有些情况下,网络抖动是很正常的现象,但一会又链接正常。
个人感觉应该要处理一下, 由于是新手,可能提的问题不是很妥当,望理解

Originally created by @Owen-Zhang on GitHub (Jan 16, 2021). Original GitHub issue: https://github.com/fatedier/frp/issues/2192 首先作者写的这个工具很好,我们公司也在用,最近有空进来学习一下源码 客户端向服务端(frpc->frps)发送心跳服务,如果在某个时间点上出现网络抖动,不应该直接关闭服务吧 control.go -> msgHandler() -> ``` go for { select { //... case <-hbCheck.C: if time.Since(ctl.lastPong) > time.Duration(ctl.clientCfg.HeartbeatTimeout)*time.Second { xl.Warn("heartbeat timeout") // let reader() stop ctl.conn.Close() return //这里直接返回,并关闭了conn } } } ``` 在有些情况下,网络抖动是很正常的现象,但一会又链接正常。 个人感觉应该要处理一下, 由于是新手,可能提的问题不是很妥当,望理解
gitea-mirror 2026-05-05 13:07:26 -06:00
Author
Owner

@fatedier commented on GitHub (Jan 17, 2021):

心跳超时是有阈值和次数要求的,网络抖动,会在 TCP 层面上保证可靠传输,应用层无需处理。心跳主要解决网络中断,上层察觉不到连接断开的问题。

<!-- gh-comment-id:761724849 --> @fatedier commented on GitHub (Jan 17, 2021): 心跳超时是有阈值和次数要求的,网络抖动,会在 TCP 层面上保证可靠传输,应用层无需处理。心跳主要解决网络中断,上层察觉不到连接断开的问题。
Author
Owner

@github-actions[bot] commented on GitHub (Mar 4, 2021):

Issues go stale after 45d of inactivity. Stale issues rot after an additional 10d of inactivity and eventually close.

<!-- gh-comment-id:790205645 --> @github-actions[bot] commented on GitHub (Mar 4, 2021): Issues go stale after 45d of inactivity. Stale issues rot after an additional 10d of inactivity and eventually close.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#1749
No description provided.