mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #4966] [Bug]: Remote Node lastOnline API returns 404 while node test succeeds #3485
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#3485
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 @Flylink on GitHub (Jun 5, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4966
Describe the bug
Bug Report: Remote Node
lastOnlineAPI returns 404 while node test succeedsVersion
Description
A remote node can be added successfully and passes the connection test in the panel.
The remote panel is accessible through HTTPS and the configured base path.
However, the main panel continuously reports:
Environment
Main node:
Remote node:
What works
Manual verification
From the main server:
Response:
The request reaches the remote panel successfully and TLS handshake completes, but the endpoint returns 404.
Expected behavior
The remote node should expose the API endpoint required by the main panel and return a valid response for:
or the main panel should not attempt to call a non-existing endpoint.
Actual behavior
The remote node test succeeds, but the main panel continuously logs:
and manual requests to the endpoint return:
Additional notes
lastOnlineAPI endpoint.How to reproduce the problem
Install 3x-ui 3.2.8 on Server A (main node).
Install 3x-ui 3.2.8 on Server B (remote node).
Enable HTTPS on both nodes.
Configure a custom
webBasePathon the remote node.Add the remote node to the main node using the Remote Node feature.
Verify that:
Wait for the main node to start synchronizing client statistics.
Observe the log on the main node:
while the remote node itself remains accessible and functional.
Expected behavior
No response
Actual behavior
No response
Relevant logs
Screenshots
No response
3x-ui version
3.2.8
Xray-core version
No response
How did you install 3x-ui?
install.sh script
Operating system
Ubuntu 24
Which parts of the panel are affected?
No response
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
None
Before submitting
@github-actions[bot] commented on GitHub (Jun 5, 2026):
Thanks for the detailed report. After tracing through the source, here is what is actually happening and how to distinguish the two separate symptoms.
1. The manual
curlreturning 404 is expected — the endpoint existsThe
POST /panel/api/clients/lastOnlineroute is registered (web/controller/client.go:77) and has been present since at least v3.1.0.The 404 you see from unauthenticated
curlis intentional. The auth middleware (web/controller/api.go:33–55) protects every route under/panel/api. When a request arrives with no valid Bearer token and no active session, and theX-Requested-With: XMLHttpRequestheader is absent (whichcurldoes not send), the middleware callsc.AbortWithStatus(http.StatusNotFound)— HTTP 404 — rather than 401, to avoid revealing that the endpoint exists to unauthenticated scanners.Verify the endpoint works with auth:
You should get a JSON response like
{"success":true,"msg":"","obj":{}}(empty object on a fresh install with no traffic records).2. The
context deadline exceededis a genuine timeout — a separate issueThe main panel's sync job (
web/job/node_traffic_sync_job.go:17) applies a total 4-second budget (nodeTrafficSyncRequestTimeout = 4s) shared across all three sequential calls insideFetchTrafficSnapshot(web/runtime/remote.go:390–416):GET panel/api/inbounds/listPOST panel/api/clients/onlinesPOST panel/api/clients/lastOnlineIf the first two calls consume most of those 4 seconds, the third gets a near-expired context and fails immediately with
context deadline exceeded. This is particularly likely with geographically distant servers or high-latency connections.3. Potential TLS mismatch (actual bug candidate)
There is a discrepancy in TLS handling:
nodeHTTPClientFor(n)(web/service/node.go:55), which respects the per-node TLS Verification Mode (verify / skip / pin) set in the node configuration.do()(web/runtime/remote.go:83) use a sharedremoteHTTPClientwith no TLS customization — standard system-CA verification only.If your remote node's HTTPS certificate is self-signed or issued by a private CA, and you set the node's TLS Verification Mode to skip (or pin), the connection test will pass but every
do()API call — includinginbounds/list,onlines, andlastOnline— will fail due to TLS certificate rejection.A TLS failure normally surfaces as a certificate error string (e.g.
x509: certificate signed by unknown authority), notcontext deadline exceeded. However, in some network environments (e.g. behind a terminating load balancer that stalls on unrecognised certificates) TLS failures can manifest as hangs that are then cut by the context deadline.Diagnostic steps
Run the authenticated curl above. If it returns a 200 with
success:true, the endpoint and token are fine and the timeout is a latency/budget issue. If it returns an error, note the exact error.Check your node's TLS Verification Mode in the main panel → Nodes → edit node. If it is set to skip or pin, that explains why the connection test works but API syncs fail (until the
remoteHTTPClientis also made to respect that setting).Check your main-panel logs for other warnings from the same sync cycle, specifically:
node traffic sync: fetch from <name> failed:— meansinbounds/listitself failed.remote <name> onlines fetch failed:— meansonlinesalso timed out.If you only see the
lastOnlinewarning, the budget exhaustion explanation is most likely.Measure round-trip latency from the main server to the remote (
pingorcurl -o /dev/null -w '%{time_total}' ...). If each call takes >1 s, three calls will reliably exceed the 4 s budget.If the TLS mismatch (point 3 above) is confirmed to be the root cause here, a fix would require
do()to build a per-node HTTP client that honoursTlsVerifyMode, the same wayProbealready does — similar to thenodeHTTPClientForfunction inweb/service/node.go.@Flylink commented on GitHub (Jun 5, 2026):
ping avg = 40.7 ms
packet loss = 0%
curl time_total = 0.151s
@Flylink commented on GitHub (Jun 5, 2026):
Additional diagnostic result:
From the main server, an unauthenticated request to the same endpoint returns immediately:
Result:
The response is immediate, TLS handshake succeeds, and the remote panel is reachable.
However, the background node sync job still logs:
So the network connection itself does not hang. The timeout appears to happen only during the authenticated API request made by the sync job.
@MHSanaei
@Flylink commented on GitHub (Jun 5, 2026):
I tested with the real API token.
Both authenticated requests return 200 OK:
GET /panel/api/inbounds/list
POST /panel/api/clients/lastOnline
So the API token, endpoint, TLS and connectivity are valid.
However, the main panel sync job still logs:
POST /panel/api/clients/lastOnline: context deadline exceeded
The URL, port and basePath in the log are now correct.
This suggests the issue is inside the background sync job or its shared 4-second context budget, not in network connectivity or authentication.