Repository navigation
Description
Bug: Node stops xray on keepalive timeout and does not recover automatically
Summary
When the panel becomes unreachable (server shutdown, network issue, etc.), the node waits for the keepalive timeout and then calls Disconnect(), which stops xray. After the panel comes back online, xray does not restart automatically. Users lose access to the node until a manual docker restart is performed.
Root cause
In controller/controller.go, keepAliveTracker() calls c.Disconnect() on timeout:
if time.Since(lastRequest) >= keepAlive {
log.Println("disconnect automatically due to keep alive timeout")
c.Disconnect() // stops xray, sets backend = nil, no auto-restart
}Disconnect() shuts down the backend and sets c.backend = nil. There is no logic to restart xray when the panel reconnects — Connect() only starts monitoring goroutines, not the backend.
This means any temporary panel unavailability (reboot, network blip, deploy) longer than the keepAlive interval will kill xray on all nodes permanently until manual intervention.
Suggested fix
On keepalive timeout, stop monitoring goroutines and enter a degraded state, but keep xray running. On reconnect from the panel, clear the degraded flag, perform a full user and config sync, then resume normal operation.
Xray should never be stopped due to a lost panel connection — only due to an explicit operator action.
Steps to reproduce
- Set keepAlive to 30s on the node in the panel
- Confirm xray is running and panel is polling the node (
GetStats/GetBackendStatsin logs) - Block all traffic from/to the panel IP:
ufw deny from <PANEL_IP>
ufw deny to <PANEL_IP>
ss -K dst <PANEL_IP>
ss -K src <PANEL_IP>
- Wait for keepalive timeout
- Restore connectivity:
ufw delete deny from <PANEL_IP>
ufw delete deny to <PANEL_IP>
- Wait 2-3 minutes, check xray:
docker exec node sh -lc 'pidof xray || echo stopped'
Expected behavior
Node keeps xray running with the last known config. When panel reconnects — full sync and resume.
Actual behavior
xray stops on keepalive timeout and does not restart when panel reconnects. Manual docker restart required.
Logs
[...] Method: GetStats, Status: Success
[...] Method: GetBackendStats, Status: Success
[...] disconnect automatically due to keep alive timeout
[...] xray core stopped
2026/05/21 13:35:01 IP: <PANEL_IP>, Method: GetBackendStats, Status: Success
2026/05/21 13:35:09 IP: <PANEL_IP>, Method: GetStats, Status: Success
2026/05/21 13:35:39 disconnect automatically due to keep alive timeout
2026/05/21 13:35:39 xray core stopped
root@Abob:# date# docker ps -a
Thu May 21 01:48:53 PM UTC 2026
root@Abob:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b7c2cf308a03 pasarguard/node:latest "./main" 50 minutes ago Up 50 minutes node
root@Abob:~#
After panel restored — no xray restart, pidof xray returns empty.
Environment
- Node version: 0.4.3
- Image:
pasarguard/node:latest - xray version: 26.3.27
- keepAlive setting: 30s
- timeouts 10/15
Activity
Nafanya1337 commentedon May 21, 2026
some script for testing on your node