mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5250] [Bug]: Online Client Log Issue #3676
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#3676
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ArminDeihim on GitHub (Jun 13, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5250
Describe the bug
There is issue with showing Online Clients in the Panel:
The online clients showing on "Clients" page is mismatch with online clients that are showing on "Inbounds" page at the same time. It seems they are not synchronised. For example when the Clients page shows 5 clients online the Inbounts page shows only 3 clients online at that time. The Clients page doesn't refresh quickly enough and it has a log delay that shows a client online long after they have been disconnected.
How to reproduce the problem
1- Check the online total clients reported on "Clients" page and compare that to the online clients that are showing on Inbounds page at same time. You will find that number of total clients on "Clients" page is always higher that clients that are really online online and showing on "Inbounds" page.
Expected behavior
1- Expecting both "Inbounds" and "Clients" page show the same numbers of online clients at same time. In other word that should be synchronised.
Actual behavior
No response
Relevant logs
Screenshots
No response
3x-ui version
3.3.1
Xray-core version
26.6.1
How did you install 3x-ui?
install.sh script
Operating system
Ubuntu 24
Which parts of the panel are affected?
Statistics / traffic counters
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
No — direct access
Before submitting
@github-actions[bot] commented on GitHub (Jun 13, 2026):
Both behaviors are confirmed in the v3.3.1 source and share a common root cause: the Xray stats API reports user traffic as a single per-email aggregate (
user>>>email>>>traffic>>>uplink/downlink) with no per-inbound breakdown. The panel infers which inbound was active by cross-referencing the inbound-level stats (inbound>>>tag>>>traffic>>>uplink/downlink), but that inference has a failure window that produces both symptoms.How online state is computed
The
XrayTrafficJobruns every ~5 s (internal/web/job/xray_traffic_job.go). Each tick it:clientTraffics) and per-inbound tag traffic deltas (traffics) from Xray's gRPC stats API.activeEmails.GetUsersStats(thestatsUserOnlineAPI, which the running core at Xray 26.6.1 does), it adds idle-but-connected clients — those with an open TCP session but zero bytes moved this poll — toactiveEmailsas well.activeInboundTagsonly from inbound-level tags that carried a non-zero delta this tick (step 1; connection-based clients from step 3 contribute no inbound tag here).RefreshLocalOnlineClients(activeEmails, activeInboundTags), which records the current timestamp for each email and tag, then prunes anything older than a 20 s grace window (onlineGracePeriodMs = 20000,internal/web/service/inbound_node.go:142).The Clients page reads the flat
onlineClientslist — the union of every email within the grace window (internal/web/service/client_paging.go:132). The Inbounds page receives a richer WebSocket payload that includesactiveInbounds(a per-GUID map of inbound tags that recently carried bytes). The frontend gates per-inbound online markers behind a check (frontend/src/pages/inbounds/useInbounds.ts:225):Issue 1 — count divergence
An idle-but-connected client (open session, no bytes in the current 5 s window) is detected by
GetUsersStatsand added toactiveEmails, so their entry inlocalLastOnlineis refreshed every poll while the connection is open. However, their inbound tag only gets refreshed inlocalInboundLastActivewhen actual bytes transit that inbound. Once the client has been idle for 20 s, the tag expires fromlocalActiveInbounds, while the email stays current. At that pointGetActiveInboundsByGuid()returns an empty (or tag-absent) map, the frontend falls through toactiveForNode === undefined → inboundActive = true, butnodeOnlinehas the email — which is the opposite of the intended scenario. Alternatively, ifactiveForNodeis a non-empty set that simply lacks this inbound's tag,inboundActive = falseand the client disappears from all per-inbound views. Either way, the Clients page (email-level, no gating) and the Inbounds page (email + tag gating) can diverge.The 20 s grace window is intentional headroom to survive polls where a session produces no bytes (
internal/web/service/inbound_node.go:137–142), but the window for tags and the window for emails can desynchronize when the connection-API path keeps an email alive after the tag has aged out.Issue 2 — client shown online on all attached inbounds
The per-inbound gating introduced to address issue #4859 (comment in
xray_traffic_job.golines 102–113) works correctly for clients actively moving bytes: only the inbound tags that saw traffic are included inactiveInbounds, so inbounds with no traffic for that client are excluded. The failure mode appears when:activeInboundTagsis empty for the panel (no inbound carried traffic in the current tick), oractiveByGuidRefon the frontend (initial page load before the first REST or WebSocketactiveInboundspayload arrives).In both cases the frontend's fallback
activeForNode === undefinedevaluatesinboundActive = truefor every inbound, and the email-level online signal then shows the client as online on all of them.Underlying constraint
The Xray core does not expose a per-inbound, per-user online signal.
GetUsersStatsreturns(email, []ip)globally, with no inbound attribution. The panel approximates per-inbound presence by correlating email-level and inbound-level traffic deltas, which works when both signals are in the same 20 s window but breaks for idle connections (kept alive by the connection API but no bytes to refresh the tag).Steps that would help a contributor diagnose further
activeInboundsfield in the WebSockettrafficmessage. If it is an empty object{}or the panel's GUID key is absent while a client shows as online on all inbounds, that confirms the grace-window desync described above.This reply was generated automatically by the issue-triage assistant; a maintainer may follow up.