VLESS > WG proxy chain stops working after switching WiFi
Integrity requirements
- [x] I have read all the comments in the issue template and ensured that this issue meet the requirements.
- [x] I confirm that I have read the documentation, understand the meaning of all the configuration items I wrote, and did not pile up seemingly useful options or default values.
- [x] I provided the complete config and logs, rather than just providing the truncated parts based on my own judgment.
- [x] I searched issues and did not find any similar issues.
- [x] The problem can be successfully reproduced in the latest Release
Description
Wireguard does not try to reconnect after switch from WiFi to cellular, when using Wireguard -> VLESS proxy chain.
Reproduction Method
For some reason, this bug can only be reproduced on android phones. I did not find any method to reproduce this bug on desktop.
- Download https://github.com/lhear/SimpleXray
- Import client config
- Connect phone to WiFi
- Start xray server on another device that is connected to the same WiFi, with the provided server config
- Start SimpleXray. Make sure Wireguard->VLESS chain works
- Disconnect and reconnect to WiFi
- Wireguard->VLESS chain stops working
Client config
{
"inbounds": [
{
"listen": "127.0.0.1",
"port": 10808,
"protocol": "socks",
"settings": {
"auth": "noauth",
"udp": true
},
"tag": "socks"
}
],
"log": {
"access": "",
"loglevel": "debug"
},
"outbounds": [
{
"protocol": "wireguard",
"settings": {
"address": [
"10.2.0.2/32"
],
"kernelMode": false,
"peers": [
{
"allowedIPs": [
"0.0.0.0/0",
"::/0"
],
"endpoint": "PROTONVPN_WG:51820",
"keepAlive": 60,
"preSharedKey": "",
"publicKey": ""
}
],
"secretKey": "",
"workers": 2
},
"streamSettings": {
"network": "tcp",
"sockopt": {
"dialerProxy": "VLESS"
}
}
},
{
"protocol": "vless",
"settings": {
"vnext": [
{
"address": "ADDRESS OF THE SERVER",
"port": 8008,
"users": [
{
"encryption": "none",
"id": "3d6d811e-0844-489e-9b04-ff1f20d29332",
"level": 0
}
]
}
]
},
"tag": "VLESS"
}
]
}
Server config
{
"inbounds": [
{
"protocol": "vless",
"port": 8008,
"settings": {
"clients": [
{
"id": "3d6d811e-0844-489e-9b04-ff1f20d29332"
}
],
"decryption": "none"
},
"tag": "VLESS"
}
],
"log": {
"loglevel": "warning"
},
"outbounds": [
{
"protocol": "freedom"
}
]
}
Client log
[Error] peer(lZkX…6zgY) - Failed to send data packets: io: read/write on closed pipe
[Error] peer(lZkX…6zgY) - Failed to send data packets: io: read/write on closed pipe
[Error] peer(lZkX…6zgY) - Failed to send data packets: io: read/write on closed pipe
[Error] peer(lZkX…6zgY) - Failed to send data packets: io: read/write on closed pipe
[Error] peer(lZkX…6zgY) - Failed to send handshake initiation: io: read/write on closed pipe
[Error] peer(lZkX…6zgY) - Failed to send data packets: io: read/write on closed pipe
[Error] peer(lZkX…6zgY) - Failed to send data packets: io: read/write on closed pipe
[Error] peer(lZkX…6zgY) - Failed to send data packets: io: read/write on closed pipe
[Error] peer(lZkX…6zgY) - Failed to send data packets: io: read/write on closed pipe
[Error] peer(lZkX…6zgY) - Failed to send data packets: io: read/write on closed pipe
[Error] peer(lZkX…6zgY) - Failed to send data packets: io: read/write on closed pipe
[Error] peer(lZkX…6zgY) - Failed to send data packets: io: read/write on closed pipe
[Error] peer(lZkX…6zgY) - Failed to send data packets: io: read/write on closed pipe
[Error] peer(lZkX…6zgY) - Failed to send data packets: io: read/write on closed pipe
Server log
2025/11/13 21:51:04.557245 [Warning] core: Xray 25.10.15 started
2025/11/13 21:51:53.209011 from tcp:192.168.2.95:46000 accepted udp:PROTONVPN_WG:51820
2025/11/13 22:01:34.667540 from tcp:192.168.2.66:41516 accepted udp:PROTONVPN_WG:51820
不处理第三方客户端遇到的问题
I think this is caused by this line:
https://github.com/XTLS/Xray-core/blob/cb4f943f5065c1ff93367be4027ef27254b52f1c/proxy/wireguard/bind.go#L156
Here it checks the error type. If it's EOF, then it discards endpoint.conn.
But, for some reason, err is io: read/write on closed pipe on android, causing endpoint.conn to never be discarded. So c.Read will always fail if the underlying VLESS connection disconnects.
不处理第三方客户端遇到的问题
这个是 xray 内核的问题,和第三方客户端无关
你可以把这个错误检查修正再测试吗 这个wireguard代码不好槽过不止一次两次了
改成
if err != nil && (errors.Is(err, io.EOF) || errors.Is(err, io.ErrClosedPipe)) {
就没问题了
这里不应该是单纯的 if err != nil 吗 好像很奇怪 不知道意义是什么
我也觉得
~~先这样吧,我看这块代码三年没动过了,改成 if err != nil 说不定有啥大坑~~