[Bug]: Xray-core VLESS+TUN 模式下 Moonlight 串流连接失败 (RTSP handshake failed: -1)
Author: codexssCreated Mar 26, 2026Updated Sep 2, 2026
### 完整性要求
- [x] 我保证阅读了文档,了解所有我编写的配置文件项的含义,而不是大量堆砌看似有用的选项或默认值。
- [x] 我读完了 issue 模板中的所有注释,确保填写符合要求。
- [x] 我提供了完整的配置文件和日志,而不是出于自己的判断只给出截取的部分。
- [x] 我搜索了 issues, 没有发现已提出的类似问题。
- [x] 问题在 Release 最新的版本上可以成功复现
### 描述
在使用 Xray-core 的 TUN 模式进行组网时,Moonlight 客户端无法成功连接到 Host 端进行串流。
具体症状:Moonlight 能够发现主机,但在点击开始串流时,报错 RTSP handshake failed: Error -1。
对比测试:
~~在相同网络环境下,切换为 Clash Party 的 TUN 模式,串流功能完全正常。~~
~~已确认防火墙和端口转发规则已正确配置(TCP 48010, UDP 48000, UDP 48010)。~~
~~初步结论:排除防火墙、网络连通性或应用本身的问题,怀疑是 Xray-core 在处理 Moonlight 的 RTSP 握手协议或相关 UDP 流量转发时存在某种不兼容。~~
经过进一步测试,发现问题似乎与 **VLESS 协议的具体实现** 有关,而非纯粹的 TUN 问题:
* **VMESS+xhttp/ws (TUN mode)**: Moonlight 串流 **完全正常**。
* **VLESS+xhttp/ws (TUN mode)**: Moonlight 报错 `RTSP handshake failed: Error -1`。
### 重现方式
设备1为【局域网A】下面PC开启sunshine作为串流服务端
设备2为【局域网A】下面软路由开启Xray作为xray服务端
设备3为【外部网络B】作为xray客户端,使用tun入口指静态路由PC到xray网卡转发组网,用moonlight连接PC串流
### 客户端配置
{
"log": {
"loglevel": "debug"
},
"inbounds": [
{
"protocol": "tun",
"settings": {
"name": "XRAY"
}
}
],
"outbounds": [
{
"protocol": "vless",
"settings": {
"address": "example.com",
"port": 80,
"id": "uuid",
"encryption": "none"
},
"streamSettings": {
"network": "xhttp",
"xhttpSettings": {
"host": "example.com",
"path": "/path"
}
}
}
]
}
### 服务端配置
{
"log": {
"loglevel": "debug"
},
"inbounds": [
{
"tag": "VLESS",
"port": 80,
"protocol": "vless",
"settings": {
"clients": [
{
"id": "uuid"
}
],
"decryption": "none"
},
"streamSettings": {
"network": "xhttp",
"xhttpSettings": {
"path": "/path"
}
}
}
],
"outbounds": [
{
"tag": "DIRECT",
"protocol": "direct"
}
]
}
### 客户端日志
Xray 26.2.6 (Xray, Penetrates Everything.) a64ad7a (go1.26.1 windows/amd64)
A unified platform for anti-censorship.
2026/03/26 11:11:01.801838 Using default config: D:\Xray\config.json
2026/03/26 11:11:01.809236 [Info] infra/conf/serial: Reading config: &{Name:D:\Xray\config.json Format:json}
2026/03/26 11:11:01.810839 [Debug] app/log: Logger started
2026/03/26 11:11:01.815320 Failed to find matching adapter name: 找不到元素。 (Code 0x00000490)
2026/03/26 11:11:01.898278 Using existing driver 0.14
2026/03/26 11:11:01.909281 Creating adapter
2026/03/26 11:11:01.986850 [Info] proxy/tun: XRAY created
2026/03/26 11:11:01.990506 [Info] proxy/tun: XRAY up
2026/03/26 11:11:02.002876 [Warning] core: Xray 26.2.6 started
2026/03/26 11:11:05.605534 [Info] [2121884602] proxy/tun: processing from udp:198.18.0.2:10004 to udp:255.255.255.255:10004
2026/03/26 11:11:05.605534 [Info] [2121884602] app/dispatcher: default route for udp:255.255.255.255:10004
2026/03/26 11:11:05.606064 [Debug] [2121884602] transport/internet/splithttp: XMUX: creating xmuxClient because xmuxClients is empty
2026/03/26 11:11:05.606064 [Info] [2121884602] transport/internet/splithttp: XHTTP is dialing to tcp:example:80, mode packet-up, HTTP version 1.1, host example
2026/03/26 11:11:05.605534 from udp:198.18.0.2:10004 accepted udp:255.255.255.255:10004
2026/03/26 11:11:05.606064 [Debug] [2121884602] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.609011 [Info] [2815879389] proxy/tun: processing from udp:198.18.0.2:64938 to udp:255.255.255.255:22222
2026/03/26 11:11:05.609518 [Info] [2815879389] app/dispatcher: default route for udp:255.255.255.255:22222
2026/03/26 11:11:05.609665 [Debug] [2815879389] transport/internet/splithttp: XMUX: creating xmuxClient because maxConcurrency was hit, xmuxClients = 1
2026/03/26 11:11:05.609665 [Info] [2815879389] transport/internet/splithttp: XHTTP is dialing to tcp:example:80, mode packet-up, HTTP version 1.1, host example
2026/03/26 11:11:05.609665 [Info] [3058140010] proxy/tun: processing from udp:198.18.0.2:64939 to udp:255.255.255.255:22222
2026/03/26 11:11:05.609665 [Info] [3058140010] app/dispatcher: default route for udp:255.255.255.255:22222
2026/03/26 11:11:05.609665 [Debug] [3058140010] transport/internet/splithttp: XMUX: creating xmuxClient because maxConcurrency was hit, xmuxClients = 2
2026/03/26 11:11:05.610239 [Info] [2934262146] proxy/tun: processing from udp:198.18.0.2:64940 to udp:255.255.255.255:22222
2026/03/26 11:11:05.610239 [Info] [2934262146] app/dispatcher: default route for udp:255.255.255.255:22222
2026/03/26 11:11:05.610239 [Debug] [2815879389] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.610239 [Info] [3959121543] proxy/tun: processing from udp:198.18.0.2:64941 to udp:255.255.255.255:22222
2026/03/26 11:11:05.610239 [Info] [3959121543] app/dispatcher: default route for udp:255.255.255.255:22222
2026/03/26 11:11:05.610239 [Info] [3058140010] transport/internet/splithttp: XHTTP is dialing to tcp:example:80, mode packet-up, HTTP version 1.1, host example
2026/03/26 11:11:05.610239 [Debug] [3959121543] transport/internet/splithttp: XMUX: creating xmuxClient because maxConcurrency was hit, xmuxClients = 3
2026/03/26 11:11:05.610239 [Info] [3959121543] transport/internet/splithttp: XHTTP is dialing to tcp:example:80, mode packet-up, HTTP version 1.1, host example
2026/03/26 11:11:05.609665 from udp:198.18.0.2:64938 accepted udp:255.255.255.255:22222
2026/03/26 11:11:05.610239 [Info] [692762648] proxy/tun: processing from udp:198.18.0.2:64942 to udp:255.255.255.255:22222
2026/03/26 11:11:05.610745 from udp:198.18.0.2:64939 accepted udp:255.255.255.255:22222
2026/03/26 11:11:05.610745 from udp:198.18.0.2:64940 accepted udp:255.255.255.255:22222
2026/03/26 11:11:05.610745 from udp:198.18.0.2:64941 accepted udp:255.255.255.255:22222
2026/03/26 11:11:05.610745 from udp:198.18.0.2:64942 accepted udp:255.255.255.255:22222
2026/03/26 11:11:05.610745 from udp:198.18.0.2:64943 accepted udp:255.255.255.255:22222
2026/03/26 11:11:05.610745 [Info] [692762648] app/dispatcher: default route for udp:255.255.255.255:22222
2026/03/26 11:11:05.610745 [Debug] [692762648] transport/internet/splithttp: XMUX: creating xmuxClient because maxConcurrency was hit, xmuxClients = 4
2026/03/26 11:11:05.610745 [Info] [2934262146] transport/internet/splithttp: XHTTP is dialing to tcp:example:80, mode packet-up, HTTP version 1.1, host example
2026/03/26 11:11:05.610745 [Info] [692762648] transport/internet/splithttp: XHTTP is dialing to tcp:example:80, mode packet-up, HTTP version 1.1, host example
2026/03/26 11:11:05.610745 [Info] [1542112731] transport/internet/splithttp: XHTTP is dialing to tcp:example:80, mode packet-up, HTTP version 1.1, host example
2026/03/26 11:11:05.610745 [Debug] [692762648] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.610745 [Debug] [1542112731] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.611789 from udp:198.18.0.2:64945 accepted udp:255.255.255.255:22222
2026/03/26 11:11:05.611789 from udp:198.18.0.2:64946 accepted udp:255.255.255.255:22222
2026/03/26 11:11:05.611789 from udp:198.18.0.2:64947 accepted udp:255.255.255.255:22222
2026/03/26 11:11:05.611789 [Info] [3207079402] proxy/tun: processing from udp:198.18.0.2:64945 to udp:255.255.255.255:22222
2026/03/26 11:11:05.612306 [Info] [3207079402] app/dispatcher: default route for udp:255.255.255.255:22222
2026/03/26 11:11:05.612306 from udp:198.18.0.2:64948 accepted udp:255.255.255.255:22222
2026/03/26 11:11:05.612306 from udp:198.18.0.2:64949 accepted udp:255.255.255.255:22222
2026/03/26 11:11:05.612306 [Info] [378215206] proxy/tun: processing from udp:198.18.0.2:64946 to udp:255.255.255.255:22222
2026/03/26 11:11:05.612306 [Info] [378215206] app/dispatcher: default route for udp:255.255.255.255:22222
2026/03/26 11:11:05.612306 [Debug] [3207079402] transport/internet/splithttp: XMUX: creating xmuxClient because maxConcurrency was hit, xmuxClients = 6
2026/03/26 11:11:05.612306 from udp:198.18.0.2:64950 accepted udp:255.255.255.255:22222
2026/03/26 11:11:05.612306 [Info] [3207079402] transport/internet/splithttp: XHTTP is dialing to tcp:example:80, mode packet-up, HTTP version 1.1, host example
2026/03/26 11:11:05.612840 [Info] [378215206] transport/internet/splithttp: XHTTP is dialing to tcp:example:80, mode packet-up, HTTP version 1.1, host example
2026/03/26 11:11:05.612840 [Info] [2591938055] proxy/tun: processing from udp:198.18.0.2:64947 to udp:255.255.255.255:22222
2026/03/26 11:11:05.612840 [Info] [2591938055] app/dispatcher: default route for udp:255.255.255.255:22222
2026/03/26 11:11:05.613629 [Debug] [2591938055] transport/internet/splithttp: XMUX: creating xmuxClient because maxConcurrency was hit, xmuxClients = 7
2026/03/26 11:11:05.613629 [Info] [2591938055] transport/internet/splithttp: XHTTP is dialing to tcp:example:80, mode packet-up, HTTP version 1.1, host example
2026/03/26 11:11:05.613629 [Debug] [378215206] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.613629 [Debug] [3207079402] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.614134 [Debug] [2591938055] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.614134 [Info] [119133653] proxy/tun: processing from udp:198.18.0.2:64948 to udp:255.255.255.255:22222
2026/03/26 11:11:05.614134 [Info] [119133653] app/dispatcher: default route for udp:255.255.255.255:22222
2026/03/26 11:11:05.614134 [Debug] [119133653] transport/internet/splithttp: XMUX: creating xmuxClient because maxConcurrency was hit, xmuxClients = 8
2026/03/26 11:11:05.614134 [Info] [119133653] transport/internet/splithttp: XHTTP is dialing to tcp:example:80, mode packet-up, HTTP version 1.1, host example
2026/03/26 11:11:05.614134 [Info] [1715837997] proxy/tun: processing from udp:198.18.0.2:64949 to udp:255.255.255.255:22222
2026/03/26 11:11:05.614134 [Debug] [49986401] transport/internet/splithttp: XMUX: creating xmuxClient because maxConcurrency was hit, xmuxClients = 10
2026/03/26 11:11:05.614134 [Debug] [49986401] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.614984 [Info] [1218362274] proxy/tun: processing from udp:198.18.0.2:64952 to udp:255.255.255.255:3289
2026/03/26 11:11:05.614984 [Info] [1218362274] app/dispatcher: default route for udp:255.255.255.255:3289
2026/03/26 11:11:05.614984 from udp:198.18.0.2:64952 accepted udp:255.255.255.255:3289
2026/03/26 11:11:05.614984 from udp:198.18.0.2:64953 accepted udp:255.255.255.255:3289
2026/03/26 11:11:05.614984 from udp:198.18.0.2:64954 accepted udp:255.255.255.255:3289
2026/03/26 11:11:05.614984 from udp:198.18.0.2:64955 accepted udp:255.255.255.255:3289
2026/03/26 11:11:05.614984 from udp:198.18.0.2:64956 accepted udp:255.255.255.255:3289
2026/03/26 11:11:05.614984 from udp:198.18.0.2:64957 accepted udp:255.255.255.255:3289
2026/03/26 11:11:05.614984 [Debug] [1218362274] transport/internet/splithttp: XMUX: creating xmuxClient because maxConcurrency was hit, xmuxClients = 11
2026/03/26 11:11:05.615489 [Info] [4031497506] proxy/tun: processing from udp:198.18.0.2:64953 to udp:255.255.255.255:3289
2026/03/26 11:11:05.615489 [Info] [4031497506] app/dispatcher: default route for udp:255.255.255.255:3289
2026/03/26 11:11:05.615489 [Info] [1218362274] transport/internet/splithttp: XHTTP is dialing to tcp:example:80, mode packet-up, HTTP version 1.1, host example
2026/03/26 11:11:05.615489 [Info] [2584207610] proxy/tun: processing from udp:198.18.0.2:64954 to udp:255.255.255.255:3289
2026/03/26 11:11:05.615489 [Info] [2584207610] app/dispatcher: default route for udp:255.255.255.255:3289
2026/03/26 11:11:05.615489 [Debug] [4031497506] transport/internet/splithttp: XMUX: creating xmuxClient because maxConcurrency was hit, xmuxClients = 12
2026/03/26 11:11:05.615489 [Info] [4031497506] transport/internet/splithttp: XHTTP is dialing to tcp:example:80, mode packet-up, HTTP version 1.1, host example
2026/03/26 11:11:05.615489 [Debug] [1218362274] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.616013 [Debug] [2584207610] transport/internet/splithttp: XMUX: creating xmuxClient because maxConcurrency was hit, xmuxClients = 13
2026/03/26 11:11:05.616013 [Info] [2800749558] proxy/tun: processing from udp:198.18.0.2:64955 to udp:255.255.255.255:3289
2026/03/26 11:11:05.616013 [Info] [2800749558] app/dispatcher: default route for udp:255.255.255.255:3289
2026/03/26 11:11:05.616013 [Debug] [4031497506] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.616013 [Info] [2584207610] transport/internet/splithttp: XHTTP is dialing to tcp:example:80, mode packet-up, HTTP version 1.1, host example
2026/03/26 11:11:05.616013 [Info] [3639748223] proxy/tun: processing from udp:198.18.0.2:64956 to udp:255.255.255.255:3289
2026/03/26 11:11:05.616013 [Debug] [2800749558] transport/internet/splithttp: XMUX: creating xmuxClient because maxConcurrency was hit, xmuxClients = 14
2026/03/26 11:11:05.616013 [Info] [3639748223] app/dispatcher: default route for udp:255.255.255.255:3289
2026/03/26 11:11:05.624085 [Info] [49986401] proxy/vless/outbound: tunneling request to udp:255.255.255.255:22222 via example:80
2026/03/26 11:11:05.624617 [Info] [378215206] proxy/vless/outbound: tunneling request to udp:255.255.255.255:22222 via example:80
2026/03/26 11:11:05.624617 [Info] [2584207610] proxy/vless/outbound: tunneling request to udp:255.255.255.255:3289 via example:80
2026/03/26 11:11:05.624617 [Info] [119133653] proxy/vless/outbound: tunneling request to udp:255.255.255.255:22222 via example:80
2026/03/26 11:11:05.625233 [Info] [2815879389] proxy/vless/outbound: tunneling request to udp:255.255.255.255:22222 via example:80
2026/03/26 11:11:05.625233 [Debug] [49986401] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.625737 [Info] [3959121543] proxy/vless/outbound: tunneling request to udp:255.255.255.255:22222 via example:80
2026/03/26 11:11:05.626269 [Debug] [378215206] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.626269 [Info] [958476226] proxy/vless/outbound: tunneling request to udp:255.255.255.255:3289 via example:80
2026/03/26 11:11:05.626269 [Debug] [119133653] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.626269 [Debug] [2584207610] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.626269 [Info] [2121884602] proxy/vless/outbound: tunneling request to udp:255.255.255.255:10004 via example:80
2026/03/26 11:11:05.626269 [Debug] [2815879389] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.626934 [Info] [1715837997] proxy/vless/outbound: tunneling request to udp:255.255.255.255:22222 via example:80
2026/03/26 11:11:05.627439 [Info] [2934262146] proxy/vless/outbound: tunneling request to udp:255.255.255.255:22222 via example:80
2026/03/26 11:11:05.627575 [Debug] [958476226] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.627575 [Debug] [3959121543] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.627575 [Debug] [2121884602] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.627575 [Info] [3058140010] proxy/vless/outbound: tunneling request to udp:255.255.255.255:22222 via example:80
2026/03/26 11:11:05.628081 [Debug] [1715837997] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.628081 [Debug] [2934262146] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.628081 [Info] [2591938055] proxy/vless/outbound: tunneling request to udp:255.255.255.255:22222 via example:80
2026/03/26 11:11:05.628081 [Info] [4031497506] proxy/vless/outbound: tunneling request to udp:255.255.255.255:3289 via example:80
2026/03/26 11:11:05.628081 [Debug] [3058140010] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.628081 [Debug] [2591938055] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.628614 [Info] [1218362274] proxy/vless/outbound: tunneling request to udp:255.255.255.255:3289 via example:80
2026/03/26 11:11:05.628720 [Info] [1542112731] proxy/vless/outbound: tunneling request to udp:255.255.255.255:22222 via example:80
2026/03/26 11:11:05.628720 [Debug] [4031497506] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.628720 [Info] [3639748223] proxy/vless/outbound: tunneling request to udp:255.255.255.255:3289 via example:80
2026/03/26 11:11:05.628720 [Debug] [1542112731] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.628720 [Debug] [1218362274] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.628720 [Debug] [3639748223] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.629226 [Info] [2800749558] proxy/vless/outbound: tunneling request to udp:255.255.255.255:3289 via example:80
2026/03/26 11:11:05.629765 [Info] [692762648] proxy/vless/outbound: tunneling request to udp:255.255.255.255:22222 via example:80
2026/03/26 11:11:05.629765 [Debug] [2800749558] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.629765 [Info] [3207079402] proxy/vless/outbound: tunneling request to udp:255.255.255.255:22222 via example:80
2026/03/26 11:11:05.629765 [Debug] [692762648] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.630281 [Debug] [3207079402] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.655744 [Debug] [2584207610] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.655744 [Debug] [119133653] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.655744 [Debug] [2815879389] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.655744 [Debug] [49986401] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.656767 [Debug] [2121884602] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.656767 [Debug] [1715837997] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.657819 [Debug] [2591938055] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.658533 [Debug] [958476226] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.659037 [Debug] [2934262146] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.660042 [Debug] [692762648] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.660042 [Debug] [4031497506] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.661552 [Debug] [3959121543] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.665266 [Debug] [2800749558] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.676441 [Debug] [1218362274] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.687303 [Debug] [1715837997] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.687303 [Debug] [2121884602] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.688318 [Debug] [2591938055] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.691756 [Debug] [3959121543] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.701810 [Debug] [378215206] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.706900 [Debug] [1218362274] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.729551 [Debug] [1542112731] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:05.736378 [Debug] [3639748223] transport/internet: dialing to tcp:example:80
2026/03/26 11:11:06.158136 [Info] [4032419897] proxy/tun: processing from tcp:198.18.0.2:37023 to tcp:192.168.0.4:47989
2026/03/26 11:11:06.158136 [Info] [4032419897] app/dispatcher: default route for tcp:192.168.0.4:47989
2026/03/26 11:Source: XTLS/Xray-core