[GH-ISSUE #3543] 代理端持续登录不上,导致frps疑似出现内存泄漏 #2824

Closed
opened 2026-05-05 13:49:39 -06:00 by gitea-mirror · 8 comments
Owner

Originally created by @itshaungmu on GitHub (Jul 24, 2023).
Original GitHub issue: https://github.com/fatedier/frp/issues/3543

Bug Description

frp客户端一直在尝试登录到frps服务端,frps服务端显示登录成功,但是客户端持续显示登录失败。frps服务端缓慢增长直至触发oom。此时连接代理不可用,kill客户端后代理注册恢复正常。

frpc Version

0.48.0

frps Version

0.48.0

System Architecture

amd64

Configurations

[common]
server_addr = x.x.x.x
server_port = 5000
tls_enable = true
tcp_mux = true

[api]
local_port = 443
type = tcp
local_ip = 127.0.0.1
[web]
local_port = 80
type = tcp
local_ip = 127.0.0.1

Logs

客户端反复出现:

[I] [service.go:214] [d3e3d2791485238d] try to reconnect to server...
[W] [service.go:221] [d3e3d2791485238d] reconnect to server error: i/o deadline reached, wait 20s for another retry

服务端:反复出现 Replaced by client , 无proxy注册成功信息

19:27:57 [I] [service.go:500] [d3e3d2791485238d] client login info: ip [x.x.x.x:7602] version [0.48.0] hostname [] os [linux] arch [amd64]
19:27:57 [I] [control.go:280] [d3e3d2791485238d] Replaced by client [d3e3d2791485238d]
19:28:27 [I] [control.go:280] [d3e3d2791485238d] Replaced by client [d3e3d2791485238d]
19:28:27 [I] [service.go:500] [d3e3d2791485238d] client login info: ip [x.x.x.x:61302] version [0.48.0] hostname [] os [linux] arch [amd64]

Steps to reproduce

目前无发现复现手段

Affected area

  • Docs
  • Installation
  • Performance and Scalability
  • Security
  • User Experience
  • Test and Release
  • Developer Infrastructure
  • Client Plugin
  • Server Plugin
  • Extensions
  • Others
Originally created by @itshaungmu on GitHub (Jul 24, 2023). Original GitHub issue: https://github.com/fatedier/frp/issues/3543 ### Bug Description frp客户端一直在尝试登录到frps服务端,frps服务端显示登录成功,但是客户端持续显示登录失败。frps服务端缓慢增长直至触发oom。此时连接代理不可用,kill客户端后代理注册恢复正常。 ### frpc Version 0.48.0 ### frps Version 0.48.0 ### System Architecture amd64 ### Configurations [common] server_addr = x.x.x.x server_port = 5000 tls_enable = true tcp_mux = true [api] local_port = 443 type = tcp local_ip = 127.0.0.1 [web] local_port = 80 type = tcp local_ip = 127.0.0.1 ### Logs 客户端反复出现: ``` [I] [service.go:214] [d3e3d2791485238d] try to reconnect to server... [W] [service.go:221] [d3e3d2791485238d] reconnect to server error: i/o deadline reached, wait 20s for another retry ``` 服务端:反复出现 Replaced by client , 无proxy注册成功信息 ``` 19:27:57 [I] [service.go:500] [d3e3d2791485238d] client login info: ip [x.x.x.x:7602] version [0.48.0] hostname [] os [linux] arch [amd64] 19:27:57 [I] [control.go:280] [d3e3d2791485238d] Replaced by client [d3e3d2791485238d] 19:28:27 [I] [control.go:280] [d3e3d2791485238d] Replaced by client [d3e3d2791485238d] 19:28:27 [I] [service.go:500] [d3e3d2791485238d] client login info: ip [x.x.x.x:61302] version [0.48.0] hostname [] os [linux] arch [amd64] ``` ### Steps to reproduce 目前无发现复现手段 ### Affected area - [ ] Docs - [ ] Installation - [X] Performance and Scalability - [ ] Security - [ ] User Experience - [ ] Test and Release - [ ] Developer Infrastructure - [ ] Client Plugin - [ ] Server Plugin - [ ] Extensions - [ ] Others
gitea-mirror 2026-05-05 13:49:39 -06:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@fatedier commented on GitHub (Jul 24, 2023):

看不出问题

<!-- gh-comment-id:1647761326 --> @fatedier commented on GitHub (Jul 24, 2023): 看不出问题
Author
Owner

@itshaungmu commented on GitHub (Jul 24, 2023):

有没有可能是这里持续阻塞,导致登录请求超时,所以客户端是显示超时,服务端不停产生goroutine导致内存上涨。
image

<!-- gh-comment-id:1647777653 --> @itshaungmu commented on GitHub (Jul 24, 2023): 有没有可能是这里持续阻塞,导致登录请求超时,所以客户端是显示超时,服务端不停产生goroutine导致内存上涨。 ![image](https://github.com/fatedier/frp/assets/44562010/9cc17924-fff1-4773-8ac3-1d42ee362a19)
Author
Owner

@itshaungmu commented on GitHub (Jul 24, 2023):

看不出问题

	if oldCtl := svr.ctlManager.Add(loginMsg.RunID, ctl); oldCtl != nil {
		oldCtl.allShutdown.WaitDone()
	} else {
       	        time.Sleep(60*time.Second)
        }
        
	ctl.Start()

这样就复现了相同的日志情况

<!-- gh-comment-id:1647859567 --> @itshaungmu commented on GitHub (Jul 24, 2023): > 看不出问题 ``` if oldCtl := svr.ctlManager.Add(loginMsg.RunID, ctl); oldCtl != nil { oldCtl.allShutdown.WaitDone() } else { time.Sleep(60*time.Second) } ctl.Start() ``` 这样就复现了相同的日志情况
Author
Owner

@fatedier commented on GitHub (Jul 24, 2023):

通过 pprof_enable 配置为 true 可以开启 prof 接口,然后查看一些相关的内存信息

<!-- gh-comment-id:1648354475 --> @fatedier commented on GitHub (Jul 24, 2023): 通过 pprof_enable 配置为 true 可以开启 prof 接口,然后查看一些相关的内存信息
Author
Owner

@fatedier commented on GitHub (Jul 24, 2023):

主要是本地如何构造这个场景l来测试

<!-- gh-comment-id:1648401362 --> @fatedier commented on GitHub (Jul 24, 2023): 主要是本地如何构造这个场景l来测试
Author
Owner

@itshaungmu commented on GitHub (Jul 25, 2023):

主要是本地如何构造这个场景l来测试

image
客户端目前超时默认是10s,服务端在LOGIN的过程处理需要在10s内完成,如果超过时间就会复现此问题。在Login的过程目前看 svr.pluginManager.Login 插件调用是同步的,我在服务端有使用Login插件。且在插件接口 sleep 60 再次复现了问题。

<!-- gh-comment-id:1648830366 --> @itshaungmu commented on GitHub (Jul 25, 2023): > 主要是本地如何构造这个场景l来测试 ![image](https://github.com/fatedier/frp/assets/44562010/80414cf2-fa66-43be-b769-c0d3ab9972b9) 客户端目前超时默认是10s,服务端在LOGIN的过程处理需要在10s内完成,如果超过时间就会复现此问题。在Login的过程目前看 svr.pluginManager.Login 插件调用是同步的,我在服务端有使用Login插件。且在插件接口 sleep 60 再次复现了问题。
Author
Owner

@itshaungmu commented on GitHub (Jul 25, 2023):

服务端出现一个日志:[control.go:315] [f038074a851789aa] write message to control connection error: stream closed
问题可能出现在这里,,
image
ctl.sendCh的大小为10,此时设置了poolCount 为20,ctl.writer内出现异常退出,导致 ctl.sendCh <- &msg.ReqWorkConn{} 持续阻塞,导致后续的login全部阻塞在等待这个control退出。
怀疑是 sendCh 和 readCh 的值没有与 poolCount 设置保持一致导致的
测试将 sendCh 和 readCh 设置大小为 poolCount 时,sleep后代理可以正常注册,control stop正常。
image

<!-- gh-comment-id:1649050092 --> @itshaungmu commented on GitHub (Jul 25, 2023): 服务端出现一个日志:[control.go:315] [f038074a851789aa] write message to control connection error: stream closed 问题可能出现在这里,, ![image](https://github.com/fatedier/frp/assets/44562010/ebb60a4e-34ca-43ac-82ab-50ae313e25df) ctl.sendCh的大小为10,此时设置了poolCount 为20,ctl.writer内出现异常退出,导致 ctl.sendCh <- &msg.ReqWorkConn{} 持续阻塞,导致后续的login全部阻塞在等待这个control退出。 怀疑是 sendCh 和 readCh 的值没有与 poolCount 设置保持一致导致的 测试将 sendCh 和 readCh 设置大小为 poolCount 时,sleep后代理可以正常注册,control stop正常。 ![image](https://github.com/fatedier/frp/assets/44562010/dc8f5711-1c5b-4f50-b45d-94d8c048bab9)
Author
Owner

@fatedier commented on GitHub (Jul 25, 2023):

看起来这两个问题组合起来,确实会触发这个 bug

<!-- gh-comment-id:1649158161 --> @fatedier commented on GitHub (Jul 25, 2023): 看起来这两个问题组合起来,确实会触发这个 bug
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#2824
No description provided.