From a84c24dbfd77a1c1eb31b0763cd7ca860713f189 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Fri, 15 May 2026 11:41:12 +0200 Subject: [PATCH] fix: extend online client grace period to survive idle poll cycles The 5s grace period equalled the traffic-poll interval, so a client whose Xray stats reported a zero delta for one cycle was still dropped on the very next tick. Bump to 20s (~4 polls) so idle-but-connected sessions stay visible across momentary counter gaps without lingering long after a real disconnect. Refs #4384 --- web/service/inbound.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/service/inbound.go b/web/service/inbound.go index 82967dc9..565cef80 100644 --- a/web/service/inbound.go +++ b/web/service/inbound.go @@ -1516,7 +1516,12 @@ func (s *InboundService) UpdateInboundClient(data *model.Inbound, clientId strin const resetGracePeriodMs int64 = 30000 -const onlineGracePeriodMs int64 = 5000 +// onlineGracePeriodMs must comfortably exceed the 5s traffic-poll interval — +// Xray's stats counters often report a zero delta for an active session across +// a single poll, so a 5s grace would still drop the client on the next tick. +// ~4 polls of slack keeps idle-but-connected clients visible without lingering +// long after a real disconnect. +const onlineGracePeriodMs int64 = 20000 func (s *InboundService) SetRemoteTraffic(nodeID int, snap *runtime.TrafficSnapshot) (bool, error) { var structuralChange bool