mirror of
https://github.com/fatedier/frp.git
synced 2026-05-15 08:05:49 -06:00
[GH-ISSUE #4798] frpc health checks leak file descriptors on FreeBSD when type = "tcp" is enabled #3788
Labels
No labels
In Progress
WIP
WaitingForInfo
bug
doc
duplicate
easy
enhancement
future
help wanted
invalid
lifecycle/stale
need-issue-template
need-usage-help
no plan
proposal
pull-request
question
todo
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/frp#3788
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @snacsnoc on GitHub (May 16, 2025).
Original GitHub issue: https://github.com/fatedier/frp/issues/4798
Bug Description
I’m encountering a file descriptor leak in frpc 0.61.1 on FreeBSD when using TCP-based health checks.
After ~24 hours of runtime, frpc logs begin to show this repeating message:
File descriptor usage continues to grow until system-wide limits are exhausted (
kern.maxfileswas 20000, increased to 50000 as a workaround).Once exhausted, even core system services and shells begin failing with "Too many open files".
Expected behaviour:
frpc Version
0.61.1
frps Version
0.61.1
System Architecture
freebsd/amd64
Configurations
Logs
Steps to reproduce
[[proxies]]block usingtype = "tcp"healthCheck.type = "tcp"enabled with a valid but potentially unreachable localIP:localPort (e.g., 192.168.1.21:22)../frpc -c frpc.tomlAffected area
@fatedier commented on GitHub (May 19, 2025):
Can you use
ssornetstatto check the specific connection status?@fatedier commented on GitHub (May 20, 2025):
From AI Agent:
I've analyzed the fatedier/frp code, specifically client/health/health.go, to understand the reported file descriptor leak.
Explanation of the Bug and Code Involved:
The Issue's Location: The file descriptor leak occurs when frpc uses TCP health checks on FreeBSD. The error "socket: too many open files" eventually appears during the net.Dialer.DialContext call within the doTCPCheck function in client/health/health.go.
frp's Connection Handling: The doTCPCheck function in frp correctly calls conn.Close() for successfully established TCP connections:
This means frp's explicit code for managing the connection object is not the direct cause of the leak. If DialContext fails, it's the responsibility of DialContext (and the Go runtime/OS) to ensure no file descriptor is leaked for that failed attempt.
@snacsnoc commented on GitHub (May 20, 2025):
I am away but will attempt this on the original hardware when I return, thank you. I will also attempt to replicate this in a VM
@github-actions[bot] commented on GitHub (Jun 4, 2025):
Issues go stale after 14d of inactivity. Stale issues rot after an additional 3d of inactivity and eventually close.