fatedier / frp

A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.
Apache License 2.0
81.79k stars 12.86k forks source link

XTCP fails on windows #4245

Open Jerry12228 opened 1 month ago

Jerry12228 commented 1 month ago

Bug Description

日志如下(最先是使用quic协议失败, 以下是更改kcp后依然失败)

2024-05-27 10:40:12.583 [I] [sub/root.go:142] start frpc service for config file [.\frpc.json]
2024-05-27 10:40:12.603 [I] [client/service.go:294] try to connect to server...
2024-05-27 10:40:13.362 [I] [client/service.go:286] [06484294096b4d28] login to server success, get run id [06484294096b4d28]
2024-05-27 10:40:13.374 [I] [visitor/visitor_manager.go:121] [06484294096b4d28] start visitor success
2024-05-27 10:40:13.374 [I] [visitor/visitor_manager.go:172] [06484294096b4d28] visitor added: [RDP1S-p2p]
2024-05-27 10:40:14.338 [I] [visitor/xtcp.go:283] [06484294096b4d28] [RDP1S-p2p] nathole prepare success, nat type: EasyNAT, behavior: BehaviorNoChange, addresses: [202.201.94.50:65270 202.201.94.50:65270], assistedAddresses: [192.168.137.1:65270 10.20.3.70:65270]
2024-05-27 10:40:16.446 [I] [visitor/xtcp.go:309] [06484294096b4d28] [RDP1S-p2p] get natHoleRespMsg, sid [1716777614a681494b5c7abe58], protocol [kcp], candidate address [116.176.114.25:5716], assisted address [192.168.31.204:33902 172.17.0.1:33902 172.19.0.1:33902 192.168.49.1:33902 172.18.0.1:33902], detectBehavior: {Role:sender Mode:0 TTL:0 SendDelayMs:0 ReadTimeoutMs:5000 CandidatePorts:[] SendRandomPorts:0 ListenRandomPorts:0}
2024-05-27 10:40:16.484 [W] [visitor/xtcp.go:316] [06484294096b4d28] [RDP1S-p2p] make hole error: wait detect message error: read udp4 0.0.0.0:65270: wsarecvfrom: The connection has been broken due to keep-alive activity detecting a failure while the operation was in progress.

frpc Version

0.58.0

frps Version

0.58.0

System Architecture

[visitor]windows/amd64, [client]linux/arm64, [server]linux/amd64

Configurations

{
    "serverAddr": "",
    "serverPort": 7000,
    "loginFailExit": false,
    "natHoleStunServer": "stun.easyvoip.com:3478",
    "auth": {
        "method": "token",
        "token": ""
    },

    "log": {
         "to": "log.log"
    },

    "visitors": [
        {
            "name": "RDP1S-p2p",
            "type": "xtcp",
            "serverName": "RDP1S-p2p",
            "secretKey": "",
            "bindADdr": "localhost",
            "bindPort": 13389,

            "keepTunnelOpen": true,
            "protocol": "kcp"
        }
    ]
}

Logs

日志如上文提及

Steps to reproduce

No response

Affected area

xqzr commented 4 weeks ago

多连几次 https://github.com/fatedier/frp/issues/4232#issuecomment-2123779640

如果打洞失败,可以尝试多次建立连接,程序会尝试其他的打洞策略,有可能在多次重试后成功打洞。

https://gofrp.org/zh-cn/docs/features/xtcp/

fatedier commented 4 weeks ago

看上去像是 windows 环境下的特殊问题,quic-go repo 下有一个相关的 issue https://github.com/quic-go/quic-go/issues/1737

我缺乏复现环境,不是很好测试。

Jerry12228 commented 4 weeks ago

看上去像是 windows 环境下的特殊问题,quic-go repo 下有一个相关的 issue quic-go/quic-go#1737

我缺乏复现环境,不是很好测试。

Windows 所处网络环境是校园网

我应该如何测试(由于使用的是学校的多媒体所以时间不是很充分, 我能做到的大概就是拿编译好的exe运行以下然后收集日志)?

quic失败日志:

024-05-24 20:09:58.874 [I] [sub/root.go:142] start frpc service for config file [.\frpc.json]
2024-05-24 20:09:58.891 [I] [client/service.go:294] try to connect to server...
2024-05-24 20:10:00.606 [I] [client/service.go:286] [e597d4a1d7bbeea2] login to server success, get run id [e597d4a1d7bbeea2]
2024-05-24 20:10:00.619 [I] [visitor/visitor_manager.go:121] [e597d4a1d7bbeea2] start visitor success
2024-05-24 20:10:00.619 [I] [visitor/visitor_manager.go:172] [e597d4a1d7bbeea2] visitor added: [RDP1S-p2p]
2024-05-24 20:10:32.511 [I] [visitor/xtcp.go:283] [e597d4a1d7bbeea2] [RDP1S-p2p] nathole prepare success, nat type: EasyNAT, behavior: BehaviorNoChange, addresses: [202.201.94.50:58952 202.201.94.50:58952], assistedAddresses: [192.168.137.1:58952 10.20.3.70:58952]
2024-05-24 20:10:34.845 [I] [visitor/xtcp.go:309] [e597d4a1d7bbeea2] [RDP1S-p2p] get natHoleRespMsg, sid [17165526321c552c2bbee79327], protocol [quic], candidate address [116.176.114.25:5519], assisted address [192.168.31.204:53364 172.17.0.1:53364 172.19.0.1:53364 192.168.49.1:53364 172.18.0.1:53364], detectBehavior: {Role:sender Mode:0 TTL:0 SendDelayMs:0 ReadTimeoutMs:5000 CandidatePorts:[] SendRandomPorts:0 ListenRandomPorts:0}
2024-05-24 20:10:34.861 [W] [visitor/xtcp.go:316] [e597d4a1d7bbeea2] [RDP1S-p2p] make hole error: wait detect message error: read udp4 0.0.0.0:58952: wsarecvfrom: The connection has been broken due to keep-alive activity detecting a failure while the operation was in progress.
coreshowfun commented 2 weeks ago

建议检测NAT类型,如果是对称型NAT,打洞成功率极低极低,端口要随机匹配上