mirror of
https://github.com/fatedier/frp.git
synced 2026-05-15 08:05:49 -06:00
[GH-ISSUE #1335] frpc 在login登录失败时,连接关不掉 #1059
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#1059
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 @luyaotang on GitHub (Jul 23, 2019).
Original GitHub issue: https://github.com/fatedier/frp/issues/1335
问题描述:
frpc 在login登录失败时,连接关不掉,通过netstat -anp来查看还是维持着Established。这就会导致登录失败时,会创建了1000多个连接,状态还是Established。
版本:
目前用的是0.22.0,但对比了最新的0.27.2发现在相关的业务处理上代码并未变更
分析:
代码所有文件 server\service.go: Line 273。
conn.Close()这个动作并不能关掉连接,释放掉。
分析如下:在关闭前输出Remoaddr,LocalAddr,然后netsta -anp|grep portxxxx ,发现还是存在的,状态为Established。尝试使用frpConn.Close()就可以。
然后解决上面所说的连接没有关掉并释放的问题。
func (svr *Service) HandleListener(l frpNet.Listener) {
// Listen for incoming connections from client.
for {
c, err := l.Accept()
if err != nil {
log.Warn("Listener for incoming connections from client closed")
return
}
@fatedier commented on GitHub (Jul 23, 2019):
无法复现这个问题,建议更新版本在本地重新尝试验证一下。
@luyaotang commented on GitHub (Jul 23, 2019):
用了最新的release 0.27.1版本。复现流程如下,目标是让frpc和frps这两的的token不一样,引起登录失败。
1.frpc的配置:
[common]
server_addr = 192.168.22.254
server_port = 7000
token = abc123
login_fail_exit = false
[ssh]
type = tcp
local_ip = 192.168.22.254
local_port = 22
remote_port = 6000
2.frps的配置:
[common]
bind_addr = 0.0.0.0
bind_port = 7000
log_level = info
log_max_days = 3
allow_ports = 2000-3000,3001,3003,4000-50000
token = defa123
3.两边各自运行,加载配置
frpcp这边就开始报:
2019/07/23 15:24:58 [W] [service.go:82] login to server failed: authorization failed
2019/07/23 15:25:08 [E] [service.go:215] authorization failed
frps这边开始报:
2019/07/23 15:25:43 [I] [service.go:349] client login info: ip [192.168.22.30:25363] version [0.27.1] hostname [] os [windows] arch [amd64]
2019/07/23 15:25:43 [W] [service.go:291] authorization failed
4.这时候再看netstat -anp|grep frp就可以看到不断增长的连接数了。
补充go环境:
[root@zmdevserver frp]# go version
go version go1.11.5 linux/amd64
@fatedier commented on GitHub (Jul 23, 2019):
login_fail_exit = false去掉这行@fatedier commented on GitHub (Jul 23, 2019):
问题不在你指出的代码段,和
login_fail_exit的处理有关,如果你有兴趣可以看一下这部分的逻辑然后提个 PR fix。@luyaotang commented on GitHub (Jul 23, 2019):
请教一下,比较疑惑的时为什么代码conn.Close()主动断开,那个连接还是可以维持在Estableshed。
@luyaotang commented on GitHub (Jul 23, 2019):
好的。谢谢
@fatedier commented on GitHub (Jul 25, 2019):
@luyaotang Can you fix it? Or i will fix it by myself.
@luyaotang commented on GitHub (Jul 25, 2019):
能力不足,不知道怎么修。还是麻烦大神你修复。