mirror of
https://github.com/fatedier/frp.git
synced 2026-05-15 16:15:49 -06:00
[GH-ISSUE #3659] nathole prepare error: discover error: write udp4 0.0.0.0:53243->:0: wsasendto: The requested address is not valid in its context. #2915
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#2915
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 @shu7734 on GitHub (Oct 11, 2023).
Original GitHub issue: https://github.com/fatedier/frp/issues/3659
Bug Description
当我在一台拥有外网IP的腾讯云服务器部署了服务端
支持TCP和KCP
指定了密钥
在家里Windows电脑上配置了stcp和xtcp的proxies
启动日志正常
然后在公司Windows电脑上再配置了两个visitors
visitors
name = "secret_tcp_visitor"
type = "stcp"
the server name you want to visitor
serverName = "secret_tcp"
secretKey = "xxxxxx"
connect this address to visitor stcp server
bindAddr = "127.0.0.1"
bindPort can be less than 0, it means don't bind to the port and only receive connections redirected from
other visitors. (This is not supported for SUDP now)
bindPort = 9000
visitors
name = "p2p_tcp_visitor"
type = "xtcp"
if the server user is not set, it defaults to the current user
serverUser = "user1"
serverName = "p2p_tcp"
secretKey = "xxxxxxx"
bindAddr = "127.0.0.1"
bindPort can be less than 0, it means don't bind to the port and only receive connections redirected from
other visitors. (This is not supported for SUDP now)
bindPort = 9001
when automatic tunnel persistence is required, set it to true
keepTunnelOpen = true
effective when keep_tunnel_open is set to true, the number of attempts to punch through per hour
maxRetriesAnHour = 8
minRetryInterval = 90
fallbackTo = "secret_tcp"
fallbackTimeoutMs = 2000
协议使用的KCP启动后
2023/10/11 09:46:26 [I] [root.go:139] start frpc service for config file [frpc.toml]
2023/10/11 09:46:26 [I] [service.go:299] [da2533a6533a034b] login to server success, get run id [da2533a6533a034b]
2023/10/11 09:46:26 [I] [visitor_manager.go:118] [da2533a6533a034b] start visitor success
2023/10/11 09:46:26 [I] [visitor_manager.go:118] [da2533a6533a034b] start visitor success
2023/10/11 09:46:26 [I] [visitor_manager.go:162] [da2533a6533a034b] visitor added: [office.secret_tcp_visitor office.p2p_tcp_visitor]
2023/10/11 09:46:26 [W] [xtcp.go:280] [da2533a6533a034b] [office.p2p_tcp_visitor] nathole prepare error: discover error: write udp4 0.0.0.0:52431->:0: wsasendto: The requested address is not valid in its context.
2023/10/11 09:47:56 [W] [xtcp.go:146] [da2533a6533a034b] [office.p2p_tcp_visitor] keepTunnelOpenWorker get tunnel connection error: no tunnel session
2023/10/11 09:47:56 [W] [xtcp.go:280] [da2533a6533a034b] [office.p2p_tcp_visitor] nathole prepare error: discover error: write udp4 0.0.0.0:49894->:0: wsasendto: The requested address is not valid in its context.
2023/10/11 09:49:26 [W] [xtcp.go:146] [da2533a6533a034b] [office.p2p_tcp_visitor] keepTunnelOpenWorker get tunnel connection error: no tunnel session
2023/10/11 09:49:26 [W] [xtcp.go:280] [da2533a6533a034b] [office.p2p_tcp_visitor] nathole prepare error: discover error: write udp4 0.0.0.0:60851->:0: wsasendto: The requested address is not valid in its context.
2023/10/11 09:50:56 [W] [xtcp.go:146] [da2533a6533a034b] [office.p2p_tcp_visitor] keepTunnelOpenWorker get tunnel connection error: no tunnel session
2023/10/11 09:50:56 [W] [xtcp.go:280] [da2533a6533a034b] [office.p2p_tcp_visitor] nathole prepare error: discover error: write udp4 0.0.0.0:53243->:0: wsasendto: The requested address is not valid in its context.
2023/10/11 09:52:26 [W] [xtcp.go:146] [da2533a6533a034b] [office.p2p_tcp_visitor] keepTunnelOpenWorker get tunnel connection error: no tunnel session
2023/10/11 09:52:26 [W] [xtcp.go:280] [da2533a6533a034b] [office.p2p_tcp_visitor] nathole prepare error: discover error: write udp4 0.0.0.0:49665->:0: wsasendto: The requested address is not valid in its context.
2023/10/11 09:53:56 [W] [xtcp.go:146] [da2533a6533a034b] [office.p2p_tcp_visitor] keepTunnelOpenWorker get tunnel connection error: no tunnel session
2023/10/11 09:53:56 [W] [xtcp.go:280] [da2533a6533a034b] [office.p2p_tcp_visitor] nathole prepare error: discover error: write udp4 0.0.0.0:52782->:0: wsasendto: The requested address is not valid in its context.
无法连接
我将两个Windows上的transport.protocol = "tcp"和kcp都试过,都是这个错误,请问这是什么原因,看起来像是少了某项参数导致目标服务器IP不存在?
frpc Version
0.52.0
frps Version
0.52.0
System Architecture
Windows/amd64
Configurations
服务端
bindAddr = "0.0.0.0"
bindPort = 7000
kcpBindPort = 7000
transport.maxPoolCount = 5
tls.force = false
webServer.addr = "0.0.0.0"
webServer.port = 7500
webServer.user = "admin"
webServer.password = "admin"
webServer.pprofEnable = false
enablePrometheus = false
log.to = "./frps.log"
log.level = "info"
log.maxDays = 3
log.disablePrintColor = false
detailedErrorsToClient = true
auth.method = "token"
auth.token = "xxxxxxx"
allowPorts = [
{ start = 2000, end = 3000 },
{ single = 3001 },
{ single = 3003 },
{ start = 4000, end = 50000 }
]
udpPacketSize = 1500
natholeAnalysisDataReserveHours = 168
Logs
No response
Steps to reproduce
...
Affected area
@shu7734 commented on GitHub (Oct 11, 2023):
已经解决了,看来隧道是打不通的,自动转回stcp了
@fatedier commented on GitHub (Oct 11, 2023):
natHoleStunServer新版本漏配置默认值了。@shu7734 commented on GitHub (Oct 11, 2023):
这个值需要手动指定为有外网IP的服务器就可以?
@fatedier commented on GitHub (Oct 11, 2023):
可以,一会儿会修复,下个版本会恢复默认值。
@shu7734 commented on GitHub (Oct 11, 2023):
这个值手动指定为有外网ip的服务器就可以?
---- Replied Message ----
| From | @.> |
| Date | 10/11/2023 15:06 |
| To | fatedier/frp @.> |
| Cc | shu7734 @.>,
State @.> |
| Subject | Re: [fatedier/frp] nathole prepare error: discover error: write udp4 0.0.0.0:53243->:0: wsasendto: The requested address is not valid in its context. (Issue #3659) |
natHoleStunServer 新版本漏配置默认值了。
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you modified the open/close state.Message ID: @.***>
@shu7734 commented on GitHub (Oct 11, 2023):
我有点疑惑,文档中没有任何涉及关于创建STUNServer的配置信息,怎么创建自己的STUMServer呢?
默认frp的Server模式不是应该可以配置使用自己的STUN Server吗?怎么默认的是使用的是easyviop服务器呢?如果他们服务器出问题我们甚至都不知道什么原因,或者说如果frpserver模式不支持STUN Server,我们有其他STUN Server可以选择的吗?
@fatedier commented on GitHub (Oct 11, 2023):
https://github.com/fatedier/frp#p2p-mode
@fatedier commented on GitHub (Oct 11, 2023):
更多的信息建议网上搜索吧,这里只讨论项目 bug/feature,不做深入的解答了。
@ppl56 commented on GitHub (Oct 11, 2023):
请问怎么解决了啊,我目前也是遇到这个问题
@shu7734 commented on GitHub (Oct 11, 2023):
在https://github.com/pradt2/always-online-stun
找个有效的服务器
然后在两端的配置中添加natHoleStunServer参数就可以了
@shu7734 commented on GitHub (Oct 12, 2023):
经过多轮测试,目前穿透的功能可能还是需要一些特定的环境或条件才能达到,我现在测试过几个环境基本都是会报错
2023/10/12 10:48:04 [I] [xtcp.go:91] [f78044be358d90d6] [p2p_tcp] get natHoleRespMsg, sid [1697078885d09196b38f127ce8], protocol [quic], candidate address [xxx.xxx.xxx.xxx:49405], assisted address [AAA.AAA.AAA.AAA:49405], detectBehavior: {Role:receiver Mode:0 TTL:4 SendDelayMs:0 ReadTimeoutMs:5000 CandidatePorts:[] SendRandomPorts:0 ListenRandomPorts:0}
2023/10/12 10:48:09 [W] [xtcp.go:99] [f78044be358d90d6] [p2p_tcp] make hole error: wait detect message error: read udp4 0.0.0.0:53287: i/o timeout
@fatedier commented on GitHub (Oct 12, 2023):
https://github.com/fatedier/frp#:~:text=Note%20that%20it%20may%20not%20work%20with%20all%20types%20of%20NAT%20devices
@shu7734 commented on GitHub (Oct 12, 2023):
感谢回复,已经配置了fallback,可用是可用的,只是在研究frp的穿透功能,穿透这块看来都是大多数软件头疼的问题,不过因为我配的是kcp,如果使用tcp穿透,可能适用的环境会更多一些,网关设备上会维持TCP端口,但是UDP一般是不会维持的,所以UDP打洞不容易成功,目前还没有时间测试
据说ZeroTier的穿透兼容性好一些,也还没有测试,可能它只是会检测到UDP打洞不成功就切到TCP打洞。只是对这类软件感兴趣,因为自己主要是撸C/C++,有空再研究
visitors
name = "secret_tcp_visitor"
type = "stcp"
the server name you want to visitor
serverName = "secret_tcp"
secretKey = "xxxxxx"
connect this address to visitor stcp server
bindAddr = "127.0.0.1"
bindPort can be less than 0, it means don't bind to the port and only receive connections redirected from
other visitors. (This is not supported for SUDP now)
bindPort = 9000
visitors
name = "p2p_tcp_visitor"
type = "xtcp"
if the server user is not set, it defaults to the current user
serverName = "p2p_tcp"
secretKey = "xxxxxx"
bindAddr = "127.0.0.1"
bindPort can be less than 0, it means don't bind to the port and only receive connections redirected from
other visitors. (This is not supported for SUDP now)
bindPort = 9001
when automatic tunnel persistence is required, set it to true
keepTunnelOpen = true
effective when keep_tunnel_open is set to true, the number of attempts to punch through per hour
maxRetriesAnHour = 8
minRetryInterval = 90
fallbackTo = "secret_tcp_visitor"
fallbackTimeoutMs = 2000
@fatedier commented on GitHub (Oct 12, 2023):
你配置了
keepTunnelOpen = true的话,就过一段时间再去连接试试,因为会尝试不同的策略,有可能哪次就成功了,还不行的话,大概率就成功不了了。@ppl56 commented on GitHub (Oct 12, 2023):
2023/10/12 11:12:11 [W] [xtcp.go:280] [fa813de5668759ca] [p2p_rtsp_visitor] nathole prepare error: discover error: wait response from stun server timeout
2023/10/12 11:12:19 [I] [xtcp.go:283] [fa813de5668759ca] [p2p_rtsp_visitor] nathole prepare success, nat type: HardNAT, behavior: BehaviorPortChanged, addresses: [117.136.80.60:41398 117.136.80.60:17892], assistedAddresses: [192.168.1.12:61937 192.168.205.1:61937 192.168.214.1:61937 192.168.43.80:61937]
2023/10/12 11:12:21 [I] [xtcp.go:309] [fa813de5668759ca] [p2p_rtsp_visitor] get natHoleRespMsg, sid [1697080337c48449f9aff74430], protocol [quic], candidate address [223.104.242.185:7146 223.104.242.185:22356], assisted address [192.168.1.111:54979 10.0.43.205:54979 192.168.0.1:54979 192.168.184.1:54979 192.168.1.105:54979], detectBehavior: {Role:receiver Mode:1 TTL:7 SendDelayMs:0 ReadTimeoutMs:5000 CandidatePorts:[{From:22346 To:22366}] SendRandomPorts:0 ListenRandomPorts:0}
2023/10/12 11:12:21 [W] [xtcp.go:316] [fa813de5668759ca] [p2p_rtsp_visitor] make hole error: wait detect message error: read udp4 0.0.0.0:61937: wsarecvfrom: The connection has been broken due to keep-alive activity detecting a failure while the operation was in progress.
2023/10/12 11:12:26 [E] [xtcp.go:179] [fa813de5668759ca] [p2p_rtsp_visitor] open tunnel error: open tunnel timeout。
我目前是这个情况,好难解决。
@fatedier commented on GitHub (Oct 12, 2023):
@ppl56 你这个就不用试了,两边都是对称型而且端口无规律,几乎不可能成功。
@shu7734 commented on GitHub (Oct 12, 2023):
如果不同策略中包含了TCP打洞的话,那我就应该不用把kcp改为tcp了,因为连不上,放那儿小时也连不上。
在06年左右研究过TCP打洞,都与服务器创建连接,由服务器的两条长连接来维护双方打洞端口,双方可以直接构造raw数据包来互发数据,还要三方共同维护两条连接的window值,这种方式几乎可以无视网络环境和网关设备,当年在实验过程中就换工作了,不知道现在TCP打洞先进到什么程度了。
@ppl56 commented on GitHub (Oct 12, 2023):
@fatedier 我这个还有其他办法嘛
@shu7734 commented on GitHub (Oct 12, 2023):
@ppl56 没办法
https://github.com/samyk/pwnat
好像这个项目看起来原理很牛B的样子,有空可以试试