[GH-ISSUE #714] 在阿里云添加了负载均衡后监听端口会导致云服务器上的FRP报错 #562

Closed
opened 2026-05-05 12:22:05 -06:00 by gitea-mirror · 6 comments
Owner

Originally created by @wuji530 on GitHub (Apr 19, 2018).
Original GitHub issue: https://github.com/fatedier/frp/issues/714

What version of frp are you using (./frpc -v or ./frps -v)?
版本:服务端客户端均为 frp_0.16.1_windows_amd64

What operating system and processor architecture are you using (go env)?
系统:WIN2008 R2 企业版 SP1 x64位系统

1、在阿里云服务器开启FRPS 服务端程序,监听端口7000, 如果在阿里云负载均衡里也添加上7000端口,就会导致服务端FRPS报错:Accept new mux stream error: broken pipe

2、在本地局域网电脑启动客户端 启动FRPC 配置TCP 30001端口 配置如下,FRPC中服务端地址是直接连接阿里云服务器地址。
[common]
server_addr = 【此处为阿里云服务器IP地址】
server_port = 7000

[range:tcp_port]
type = tcp
local_ip = 127.0.0.1
local_port = 30001
remote_port = 30001
use_encryption = false
use_compression = false

负载均衡里未添加30001端口时可以正常,一添加上30001端口就会导致 客户端FRPC连接出错,错误内容如下:

2018/04/19 11:02:52 [E] [proxy.go:438] [tcp_port_0] connect to local service [12
7.0.0.1:30001] error: dial tcp 127.0.0.1:30001: connectex: No connection could b
e made because the target machine actively refused it.

停止负载均衡监听端口后又能正常连上FRPS服务端 所以确定是阿里云负载均衡会影响到FRPS服务端。
但是我客户端FRPC未启动时,如果云服务器上开启FRPS服务端,并且负载均衡添加30001端口后,FRPS未显示错误信息,而且natstat -an [查看端口也没有发现30001端口被占用,但是一旦开FRPC客户端进行连接就会报以上错误]

Originally created by @wuji530 on GitHub (Apr 19, 2018). Original GitHub issue: https://github.com/fatedier/frp/issues/714 **What version of frp are you using (./frpc -v or ./frps -v)?** 版本:服务端客户端均为 frp_0.16.1_windows_amd64 **What operating system and processor architecture are you using (`go env`)?** 系统:WIN2008 R2 企业版 SP1 x64位系统 1、在阿里云服务器开启FRPS 服务端程序,监听端口7000, 如果在阿里云负载均衡里也添加上7000端口,就会导致服务端FRPS报错:Accept new mux stream error: broken pipe 2、在本地局域网电脑启动客户端 启动FRPC 配置TCP 30001端口 配置如下,FRPC中服务端地址是直接连接阿里云服务器地址。 [common] server_addr = 【此处为阿里云服务器IP地址】 server_port = 7000 [range:tcp_port] type = tcp local_ip = 127.0.0.1 local_port = 30001 remote_port = 30001 use_encryption = false use_compression = false 负载均衡里未添加30001端口时可以正常,一添加上30001端口就会导致 客户端FRPC连接出错,错误内容如下: 2018/04/19 11:02:52 [E] [proxy.go:438] [tcp_port_0] connect to local service [12 7.0.0.1:30001] error: dial tcp 127.0.0.1:30001: connectex: No connection could b e made because the target machine actively refused it. 停止负载均衡监听端口后又能正常连上FRPS服务端 所以确定是阿里云负载均衡会影响到FRPS服务端。 但是我客户端FRPC未启动时,如果云服务器上开启FRPS服务端,并且负载均衡添加30001端口后,FRPS未显示错误信息,而且natstat -an [查看端口也没有发现30001端口被占用,但是一旦开FRPC客户端进行连接就会报以上错误]
gitea-mirror 2026-05-05 12:22:05 -06:00
Author
Owner

@wuji530 commented on GitHub (Apr 19, 2018):

另补充:我自己写的简单的服务端程序和客户端程序,在负载均衡中添加服务器程序的监听端口,服务端软件依然可以正常运行,客户端也能正常连接

<!-- gh-comment-id:382609190 --> @wuji530 commented on GitHub (Apr 19, 2018): 另补充:我自己写的简单的服务端程序和客户端程序,在负载均衡中添加服务器程序的监听端口,服务端软件依然可以正常运行,客户端也能正常连接
Author
Owner

@wuji530 commented on GitHub (Apr 19, 2018):

之后服务端更换Linux版,在Centos6.8 系统下 运行
如果负载均衡监听7000端口 也一样会导致frps程序报错
2018/04/19 13:01:41 [W] [service.go:247] Accept new mux stream error: broken pipe

<!-- gh-comment-id:382611278 --> @wuji530 commented on GitHub (Apr 19, 2018): 之后服务端更换Linux版,在Centos6.8 系统下 运行 如果负载均衡监听7000端口 也一样会导致frps程序报错 2018/04/19 13:01:41 [W] [service.go:247] Accept new mux stream error: broken pipe
Author
Owner

@fatedier commented on GitHub (Apr 19, 2018):

根据你的描述,显然就是负载均衡器的问题了,你需要弄清楚这个组件的行为,以及对连接做了哪些控制或者修改。另外,frps 是有状态服务,只能部署一个,不能做负载均衡。

<!-- gh-comment-id:382757510 --> @fatedier commented on GitHub (Apr 19, 2018): 根据你的描述,显然就是负载均衡器的问题了,你需要弄清楚这个组件的行为,以及对连接做了哪些控制或者修改。另外,frps 是有状态服务,只能部署一个,不能做负载均衡。
Author
Owner

@wuji530 commented on GitHub (Apr 19, 2018):

我使用负载均衡的目的是因为负载均衡有5G的DDOS防护能力,另外采用负载均衡可以避免让云服务器IP暴露在外,价格也更加低廉 出故障后 重新添加负载均衡也能非常快速布置,并非要让FRPS服务器部署多个的目的。
目前看到的原因猜测是负载均衡添加端口后要检测端口状态,向服务器对应端口发送了某些检测指令,导致服务器端判断为端口被占用,而实际该端口并未占用
经过实际测试 我发现服务端开启端口后在负载均衡监听此端口会通过不断 连接进入、断开连接来探测端口是否正常开放,并未发送任何报文信息。 是否反复的连接断开来探测某端口会导致FRP以为端口被占用呢?
客户进入:100.97.199.129:144
客户离开:100.97.199.129:144
客户进入:100.97.198.131:54031
客户离开:100.97.198.131:54031
客户进入:100.109.154.130:12700
客户离开:100.109.154.130:12700
客户进入:100.109.154.3:469
客户离开:100.109.154.3:469
客户进入:100.97.198.2:31534
客户离开:100.97.198.2:31534
客户进入:100.97.199.2:53404
客户离开:100.97.199.2:53404
客户进入:100.109.153.128:59099
客户离开:100.109.153.128:59099
客户进入:100.109.153.2:15201
客户离开:100.109.153.2:15201
客户进入:100.97.198.131:7608
客户离开:100.97.198.131:7608
客户进入:100.97.199.129:64073
客户离开:100.97.199.129:64073
客户进入:100.97.198.2:5105
客户离开:100.97.198.2:5105
客户进入:100.109.154.130:16656
客户离开:100.109.154.130:16656
客户进入:100.97.199.2:7279
客户离开:100.97.199.2:7279

<!-- gh-comment-id:382816797 --> @wuji530 commented on GitHub (Apr 19, 2018): 我使用负载均衡的目的是因为负载均衡有5G的DDOS防护能力,另外采用负载均衡可以避免让云服务器IP暴露在外,价格也更加低廉 出故障后 重新添加负载均衡也能非常快速布置,并非要让FRPS服务器部署多个的目的。 目前看到的原因猜测是负载均衡添加端口后要检测端口状态,向服务器对应端口发送了某些检测指令,导致服务器端判断为端口被占用,而实际该端口并未占用 经过实际测试 我发现服务端开启端口后在负载均衡监听此端口会通过不断 连接进入、断开连接来探测端口是否正常开放,并未发送任何报文信息。 是否反复的连接断开来探测某端口会导致FRP以为端口被占用呢? 客户进入:100.97.199.129:144 客户离开:100.97.199.129:144 客户进入:100.97.198.131:54031 客户离开:100.97.198.131:54031 客户进入:100.109.154.130:12700 客户离开:100.109.154.130:12700 客户进入:100.109.154.3:469 客户离开:100.109.154.3:469 客户进入:100.97.198.2:31534 客户离开:100.97.198.2:31534 客户进入:100.97.199.2:53404 客户离开:100.97.199.2:53404 客户进入:100.109.153.128:59099 客户离开:100.109.153.128:59099 客户进入:100.109.153.2:15201 客户离开:100.109.153.2:15201 客户进入:100.97.198.131:7608 客户离开:100.97.198.131:7608 客户进入:100.97.199.129:64073 客户离开:100.97.199.129:64073 客户进入:100.97.198.2:5105 客户离开:100.97.198.2:5105 客户进入:100.109.154.130:16656 客户离开:100.109.154.130:16656 客户进入:100.97.199.2:7279 客户离开:100.97.199.2:7279
Author
Owner

@wuji530 commented on GitHub (Apr 19, 2018):

自己做了个客户端模拟反复连接断开行为,发现确实是这个原因导致FRPS服务端和FRPC客户端报错
比如 FRPC客户端配置
[range:tcp_port]
type = tcp
local_ip = 127.0.0.1
local_port = 30005
remote_port = 30005
use_encryption = false
use_compression = false

我另外一个程序反复连接断开 FRPS服务端的 30005端口,就会导致FRPC客户端不断报错
2018/04/20 01:41:45 [E] [proxy.go:438] [tcp_port_0] connect to local service [
7.0.0.1:30005] error: dial tcp 127.0.0.1:30005: connectex: No connection could
e made because the target machine actively refused it.
2018/04/20 01:41:45 [E] [proxy.go:438] [tcp_port_0] connect to local service [
7.0.0.1:30005] error: dial tcp 127.0.0.1:30005: connectex: No connection could
e made because the target machine actively refused it.
2018/04/20 01:41:45 [E] [proxy.go:438] [tcp_port_0] connect to local service [
7.0.0.1:30005] error: dial tcp 127.0.0.1:30005: connectex: No connection could
e made because the target machine actively refused it.
2018/04/20 01:41:45 [E] [proxy.go:438] [tcp_port_0] connect to local service [
7.0.0.1:30005] error: dial tcp 127.0.0.1:30005: connectex: No connection could
e made because the target machine actively refused it.
2018/04/20 01:41:46 [E] [proxy.go:438] [tcp_port_0] connect to local service [
7.0.0.1:30005] error: dial tcp 127.0.0.1:30005: connectex: No connection could
e made because the target machine actively refused it.
2018/04/20 01:41:46 [E] [proxy.go:438] [tcp_port_0] connect to local service [
7.0.0.1:30005] error: dial tcp 127.0.0.1:30005: connectex: No connection could
e made because the target machine actively refused it.
2018/04/20 01:41:46 [E] [proxy.go:438] [tcp_port_0] connect to local service [
7.0.0.1:30005] error: dial tcp 127.0.0.1:30005: connectex: No connection could
e made because the target machine actively refused it.
2018/04/20 01:41:47 [E] [proxy.go:438] [tcp_port_0] connect to local service [
7.0.0.1:30005] error: dial tcp 127.0.0.1:30005: connectex: No connection could
e made because the target machine actively refused it.

<!-- gh-comment-id:382821601 --> @wuji530 commented on GitHub (Apr 19, 2018): 自己做了个客户端模拟反复连接断开行为,发现确实是这个原因导致FRPS服务端和FRPC客户端报错 比如 FRPC客户端配置 [range:tcp_port] type = tcp local_ip = 127.0.0.1 local_port = 30005 remote_port = 30005 use_encryption = false use_compression = false 我另外一个程序反复连接断开 FRPS服务端的 30005端口,就会导致FRPC客户端不断报错 2018/04/20 01:41:45 [E] [proxy.go:438] [tcp_port_0] connect to local service [ 7.0.0.1:30005] error: dial tcp 127.0.0.1:30005: connectex: No connection could e made because the target machine actively refused it. 2018/04/20 01:41:45 [E] [proxy.go:438] [tcp_port_0] connect to local service [ 7.0.0.1:30005] error: dial tcp 127.0.0.1:30005: connectex: No connection could e made because the target machine actively refused it. 2018/04/20 01:41:45 [E] [proxy.go:438] [tcp_port_0] connect to local service [ 7.0.0.1:30005] error: dial tcp 127.0.0.1:30005: connectex: No connection could e made because the target machine actively refused it. 2018/04/20 01:41:45 [E] [proxy.go:438] [tcp_port_0] connect to local service [ 7.0.0.1:30005] error: dial tcp 127.0.0.1:30005: connectex: No connection could e made because the target machine actively refused it. 2018/04/20 01:41:46 [E] [proxy.go:438] [tcp_port_0] connect to local service [ 7.0.0.1:30005] error: dial tcp 127.0.0.1:30005: connectex: No connection could e made because the target machine actively refused it. 2018/04/20 01:41:46 [E] [proxy.go:438] [tcp_port_0] connect to local service [ 7.0.0.1:30005] error: dial tcp 127.0.0.1:30005: connectex: No connection could e made because the target machine actively refused it. 2018/04/20 01:41:46 [E] [proxy.go:438] [tcp_port_0] connect to local service [ 7.0.0.1:30005] error: dial tcp 127.0.0.1:30005: connectex: No connection could e made because the target machine actively refused it. 2018/04/20 01:41:47 [E] [proxy.go:438] [tcp_port_0] connect to local service [ 7.0.0.1:30005] error: dial tcp 127.0.0.1:30005: connectex: No connection could e made because the target machine actively refused it.
Author
Owner

@fatedier commented on GitHub (Apr 20, 2018):

127.0.0.1:30005 是你的内网服务的端口,这个错误提示不是端口被占用了,而是连接不上,确认下这个服务是否正常监听在 127.0.0.1:30005 这个地址上。

<!-- gh-comment-id:382943973 --> @fatedier commented on GitHub (Apr 20, 2018): `127.0.0.1:30005` 是你的内网服务的端口,这个错误提示不是端口被占用了,而是连接不上,确认下这个服务是否正常监听在 `127.0.0.1:30005` 这个地址上。
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#562
No description provided.