[GH-ISSUE #575] 如果frpc连接本地端口失败,则frps上的连接会永远卡住。 #447

Closed
opened 2026-05-05 12:16:48 -06:00 by gitea-mirror · 1 comment
Owner

Originally created by @gtt116 on GitHub (Dec 26, 2017).
Original GitHub issue: https://github.com/fatedier/frp/issues/575

Issue is only used for submiting bug report and documents typo. If there are same issues or answers can be found in documents, we will close it directly.
(为了节约时间,提高处理问题的效率,不按照格式填写的 issue 将会直接关闭。)

Use the commands below to provide key information from your environment:
You do NOT have to include this information if this is a FEATURE REQUEST

What version of frp are you using (./frpc -v or ./frps -v)?
bin/frps -v
0.14.1

bin/frpc -v
0.14.1

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/gos"
GORACE=""
GOROOT="/root/go"
GOTOOLDIR="/root/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build981688964=/tmp/go-build"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

Configures you used:
cat conf/frps.ini

[common]
bind_port = 7000

cat frpc.ini

[common]
server_addr = 127.0.0.1
server_port = 7000

[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 23
remote_port = 6000

Steps to reproduce the issue:

  1. 本地23端口的服务已挂
  2. 用telnet localhost 6000 模拟客户端,可以成功,但是实际frpc没有连上本地的23端口服务。
  3. 如果有很多客户端不断尝试连接 frps:6000,frps的内存占用会无限增长。。

Describe the results you received:
telnet能连接成功,但服务端无响应,且不会自动重连。

Describe the results you expected:
如果frpc连接本地服务失败,则关闭此链接。

Additional information you deem important (e.g. issue happens only occasionally):

frps logs

...
2017/12/26 14:18:26 [I] [control.go:319] [a61a8a6bb70f366c] new proxy [ssh] success
2017/12/26 14:18:28 [I] [proxy.go:76] [a61a8a6bb70f366c] [ssh] get a new work connection: [127.0.0.1:41554]

frpc logs

2017/12/26 14:18:26 [I] [control.go:277] [a61a8a6bb70f366c] login to server success, get run id [a61a8a6bb70f366c], server udp port [0]
2017/12/26 14:18:26 [I] [control.go:412] [a61a8a6bb70f366c] [ssh] start proxy success
2017/12/26 14:18:28 [E] [proxy.go:436] [ssh] connect to local service [127.0.0.1:23] error: dial tcp 127.0.0.1:23: getsockopt: connection refused

Can you point out what caused this issue (optional)

--- a/client/proxy.go
+++ b/client/proxy.go
@@ -434,6 +434,7 @@ func HandleTcpWorkConnection(localInfo *config.LocalSvrConf, proxyPlugin plugin.
                localConn, err := frpNet.ConnectServer("tcp", fmt.Sprintf("%s:%d", localInfo.LocalIp, localInfo.LocalPort))
                if err != nil {
                        workConn.Error("connect to local service [%s:%d] error: %v", localInfo.LocalIp, localInfo.LocalPort, err)
+                 remote.Close()
                        return
                }
Originally created by @gtt116 on GitHub (Dec 26, 2017). Original GitHub issue: https://github.com/fatedier/frp/issues/575 Issue is only used for submiting bug report and documents typo. If there are same issues or answers can be found in documents, we will close it directly. (为了节约时间,提高处理问题的效率,不按照格式填写的 issue 将会直接关闭。) Use the commands below to provide key information from your environment: You do NOT have to include this information if this is a FEATURE REQUEST **What version of frp are you using (./frpc -v or ./frps -v)?** bin/frps -v 0.14.1 bin/frpc -v 0.14.1 **What operating system and processor architecture are you using (`go env`)?** ``` GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/root/gos" GORACE="" GOROOT="/root/go" GOTOOLDIR="/root/go/pkg/tool/linux_amd64" GCCGO="gccgo" CC="gcc" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build981688964=/tmp/go-build" CXX="g++" CGO_ENABLED="1" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" ``` **Configures you used:** cat conf/frps.ini ``` [common] bind_port = 7000 ``` cat frpc.ini ``` [common] server_addr = 127.0.0.1 server_port = 7000 [ssh] type = tcp local_ip = 127.0.0.1 local_port = 23 remote_port = 6000 ``` **Steps to reproduce the issue:** 1. 本地23端口的服务已挂 2. 用telnet localhost 6000 模拟客户端,可以成功,但是实际frpc没有连上本地的23端口服务。 3. 如果有很多客户端不断尝试连接 frps:6000,frps的内存占用会无限增长。。 **Describe the results you received:** telnet能连接成功,但服务端无响应,且不会自动重连。 **Describe the results you expected:** 如果frpc连接本地服务失败,则关闭此链接。 **Additional information you deem important (e.g. issue happens only occasionally):** frps logs ``` ... 2017/12/26 14:18:26 [I] [control.go:319] [a61a8a6bb70f366c] new proxy [ssh] success 2017/12/26 14:18:28 [I] [proxy.go:76] [a61a8a6bb70f366c] [ssh] get a new work connection: [127.0.0.1:41554] ``` frpc logs ``` 2017/12/26 14:18:26 [I] [control.go:277] [a61a8a6bb70f366c] login to server success, get run id [a61a8a6bb70f366c], server udp port [0] 2017/12/26 14:18:26 [I] [control.go:412] [a61a8a6bb70f366c] [ssh] start proxy success 2017/12/26 14:18:28 [E] [proxy.go:436] [ssh] connect to local service [127.0.0.1:23] error: dial tcp 127.0.0.1:23: getsockopt: connection refused ``` **Can you point out what caused this issue (optional)** ``` --- a/client/proxy.go +++ b/client/proxy.go @@ -434,6 +434,7 @@ func HandleTcpWorkConnection(localInfo *config.LocalSvrConf, proxyPlugin plugin. localConn, err := frpNet.ConnectServer("tcp", fmt.Sprintf("%s:%d", localInfo.LocalIp, localInfo.LocalPort)) if err != nil { workConn.Error("connect to local service [%s:%d] error: %v", localInfo.LocalIp, localInfo.LocalPort, err) + remote.Close() return } ```
gitea-mirror 2026-05-05 12:16:48 -06:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@fatedier commented on GitHub (Dec 26, 2017):

Can you submit a PR to fix this issue?

<!-- gh-comment-id:353926165 --> @fatedier commented on GitHub (Dec 26, 2017): Can you submit a PR to fix this issue?
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#447
No description provided.