policy: restore ConnectionIdle to 120s (matches upstream v2node; fixes idle SSH/long-lived connections dropping at ~60s)#31
Conversation
Extra findings (why 30s behaves like ~60s, and how it compares to xray / V2bX defaults)The effective timeout is ~2× the configured value. 30s is far below xray's own default. xray-core defaults vs V2bX: V2bX ships the same This PR just raises the constant. A cleaner long-term fix would be to expose it as a config option like V2bX does, defaulting to something no more aggressive than xray's own default. |
This project lowered ConnectionIdle to 30s. xray enforces it with a polling activity timer, so the effective idle timeout is ~2x the value (~60s), and idle-but-healthy long-lived connections (interactive SSH, database sessions, MQTT/WebSocket) get torn down after ~60s even though the socket is fine. TCP keepalive doesn't help — it refreshes the socket, not this application-level timer. Restore it to 120, the value used by wyx2685/v2node which this project is modified from. (xray's own default is 300-600s.)
ce26a9c to
176c34e
Compare
Problem
core/xray.gosets the level-0 policyConnectionIdleto 30s:xray closes a proxied connection once there is no application-layer data for
ConnectionIdleseconds, and it enforces this with a polling activity timer (common/signal/timer.go): the check runs everyConnectionIdleseconds and only fires after a full interval with no activity following the one that consumed the previous activity token — so the effective timeout is ~2× the value, i.e. ~60s for 30.The result: idle-but-healthy long-lived connections — interactive SSH, database/Redis, MQTT, WebSocket — are dropped after ~60s of silence even though the socket is perfectly fine. TCP keepalive does not help (it refreshes the socket, not this application-level timer).
On an affected node, a packet capture of an idle proxied SSH session showed the node itself sending
FINat exactly the 60s mark, with TCP keepalives still flowing on both legs — confirming an application-level idle timeout rather than a NAT/socket issue.Context
ConnectionIdle: 120. ppnode lowered it to 30 (4× more aggressive) at some point.SessionDefault) / 600s (default manager) — so 30s is ~10–20× more aggressive than xray itself.Fix
Restore
ConnectionIdleto 120, matching upstream v2node. Verified end-to-end: with 30 an idle SSH tunnel dropped at ~60s every time; with the larger value the same tunnel stays up (no drop observed to 200s+).