[GH-ISSUE #4966] [Bug]: Remote Node lastOnline API returns 404 while node test succeeds #3485

Closed
opened 2026-10-31 20:32:46 +07:00 by bsakaguchi · 4 comments
Owner

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 lastOnline API returns 404 while node test succeeds

Version

  • 3x-ui: 3.2.8
  • Main node: 3.2.8
  • Remote node: 3.2.8

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:

WARNING - X-UI: remote-node lastOnline fetch failed:
POST panel/api/clients/lastOnline:
context deadline exceeded

Environment

Main node:

  • HTTPS enabled
  • SQLite database

Remote node:

  • HTTPS enabled
  • SQLite database
  • Fresh installation
  • Same 3x-ui version as the main node

What works

  • Remote node can be added successfully.
  • Connection test succeeds.
  • HTTPS is reachable.
  • TLS certificate is valid.
  • Panel login works.
  • Port is reachable from the main server.

Manual verification

From the main server:

curl -vk -X POST \
https://remote-domain:remote-port/randomBasePath/panel/api/clients/lastOnline

Response:

HTTP/1.1 404 Not Found

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:

/panel/api/clients/lastOnline

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:

lastOnline fetch failed

and manual requests to the endpoint return:

404 Not Found

Additional notes

  • Reinstalling the remote node does not resolve the issue.
  • Re-adding the node does not resolve the issue.
  • HTTPS, certificates, firewall rules and connectivity have been verified.
  • The issue appears to be related specifically to the lastOnline API endpoint.

How to reproduce the problem

  1. Install 3x-ui 3.2.8 on Server A (main node).

  2. Install 3x-ui 3.2.8 on Server B (remote node).

  3. Enable HTTPS on both nodes.

  4. Configure a custom webBasePath on the remote node.

  5. Add the remote node to the main node using the Remote Node feature.

  6. Verify that:

    • The remote node connection test succeeds.
    • The remote panel is reachable via browser.
    • Login to the remote panel works.
  7. Wait for the main node to start synchronizing client statistics.

  8. Observe the log on the main node:

WARNING - X-UI: remote-node lastOnline fetch failed:
POST panel/api/clients/lastOnline:
context deadline exceeded
  1. Manually test the endpoint:
curl -vk -X POST \
https://remote-node:port/basePath/panel/api/clients/lastOnline
  1. The endpoint returns:
HTTP/1.1 404 Not Found

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

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
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 `lastOnline` API returns 404 while node test succeeds ## Version * 3x-ui: 3.2.8 * Main node: 3.2.8 * Remote node: 3.2.8 ## 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: ```text WARNING - X-UI: remote-node lastOnline fetch failed: POST panel/api/clients/lastOnline: context deadline exceeded ``` ## Environment Main node: * HTTPS enabled * SQLite database Remote node: * HTTPS enabled * SQLite database * Fresh installation * Same 3x-ui version as the main node ## What works * Remote node can be added successfully. * Connection test succeeds. * HTTPS is reachable. * TLS certificate is valid. * Panel login works. * Port is reachable from the main server. ## Manual verification From the main server: ```bash curl -vk -X POST \ https://remote-domain:remote-port/randomBasePath/panel/api/clients/lastOnline ``` Response: ```text HTTP/1.1 404 Not Found ``` 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: ```text /panel/api/clients/lastOnline ``` 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: ```text lastOnline fetch failed ``` and manual requests to the endpoint return: ```text 404 Not Found ``` ## Additional notes * Reinstalling the remote node does not resolve the issue. * Re-adding the node does not resolve the issue. * HTTPS, certificates, firewall rules and connectivity have been verified. * The issue appears to be related specifically to the `lastOnline` API endpoint. ### How to reproduce the problem 1. Install 3x-ui 3.2.8 on Server A (main node). 2. Install 3x-ui 3.2.8 on Server B (remote node). 3. Enable HTTPS on both nodes. 4. Configure a custom `webBasePath` on the remote node. 5. Add the remote node to the main node using the Remote Node feature. 6. Verify that: * The remote node connection test succeeds. * The remote panel is reachable via browser. * Login to the remote panel works. 7. Wait for the main node to start synchronizing client statistics. 8. Observe the log on the main node: ```text WARNING - X-UI: remote-node lastOnline fetch failed: POST panel/api/clients/lastOnline: context deadline exceeded ``` 9. Manually test the endpoint: ```bash curl -vk -X POST \ https://remote-node:port/basePath/panel/api/clients/lastOnline ``` 10. The endpoint returns: ```text HTTP/1.1 404 Not Found ``` while the remote node itself remains accessible and functional. ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### 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 - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:32:46 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@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 curl returning 404 is expected — the endpoint exists

The POST /panel/api/clients/lastOnline route is registered (web/controller/client.go:77) and has been present since at least v3.1.0.

The 404 you see from unauthenticated curl is 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 the X-Requested-With: XMLHttpRequest header is absent (which curl does not send), the middleware calls c.AbortWithStatus(http.StatusNotFound) — HTTP 404 — rather than 401, to avoid revealing that the endpoint exists to unauthenticated scanners.

Verify the endpoint works with auth:

curl -vk -X POST \
  -H "Authorization: Bearer <your-api-token>" \
  https://remote-domain:remote-port/basePath/panel/api/clients/lastOnline

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 exceeded is a genuine timeout — a separate issue

The 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 inside FetchTrafficSnapshot (web/runtime/remote.go:390–416):

  1. GET panel/api/inbounds/list
  2. POST panel/api/clients/onlines
  3. POST panel/api/clients/lastOnline

If 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:

  • Connection test (Probe) uses nodeHTTPClientFor(n) (web/service/node.go:55), which respects the per-node TLS Verification Mode (verify / skip / pin) set in the node configuration.
  • All actual API calls via do() (web/runtime/remote.go:83) use a shared remoteHTTPClient with 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 — including inbounds/list, onlines, and lastOnline — 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), not context 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

  1. 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.

  2. 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 remoteHTTPClient is also made to respect that setting).

  3. Check your main-panel logs for other warnings from the same sync cycle, specifically:

    • node traffic sync: fetch from <name> failed: — means inbounds/list itself failed.
    • remote <name> onlines fetch failed: — means onlines also timed out.
      If you only see the lastOnline warning, the budget exhaustion explanation is most likely.
  4. Measure round-trip latency from the main server to the remote (ping or curl -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 honours TlsVerifyMode, the same way Probe already does — similar to the nodeHTTPClientFor function in web/service/node.go.

<!-- gh-comment-id:4631597189 --> @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 `curl` returning 404 is expected — the endpoint exists The `POST /panel/api/clients/lastOnline` route **is** registered (`web/controller/client.go:77`) and has been present since at least v3.1.0. The 404 you see from unauthenticated `curl` is 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 the `X-Requested-With: XMLHttpRequest` header is absent (which `curl` does not send), the middleware calls `c.AbortWithStatus(http.StatusNotFound)` — HTTP 404 — rather than 401, to avoid revealing that the endpoint exists to unauthenticated scanners. Verify the endpoint works with auth: ```bash curl -vk -X POST \ -H "Authorization: Bearer <your-api-token>" \ https://remote-domain:remote-port/basePath/panel/api/clients/lastOnline ``` 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 exceeded` is a genuine timeout — a separate issue The 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 inside `FetchTrafficSnapshot` (`web/runtime/remote.go:390–416`): 1. `GET panel/api/inbounds/list` 2. `POST panel/api/clients/onlines` 3. `POST panel/api/clients/lastOnline` If 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: - **Connection test (Probe)** uses `nodeHTTPClientFor(n)` (`web/service/node.go:55`), which respects the per-node **TLS Verification Mode** (verify / skip / pin) set in the node configuration. - **All actual API calls** via `do()` (`web/runtime/remote.go:83`) use a shared `remoteHTTPClient` with **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 — including `inbounds/list`, `onlines`, and `lastOnline` — 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`), not `context 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 1. **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. 2. **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 `remoteHTTPClient` is also made to respect that setting). 3. **Check your main-panel logs for other warnings** from the same sync cycle, specifically: - `node traffic sync: fetch from <name> failed:` — means `inbounds/list` itself failed. - `remote <name> onlines fetch failed:` — means `onlines` also timed out. If you only see the `lastOnline` warning, the budget exhaustion explanation is most likely. 4. **Measure round-trip latency** from the main server to the remote (`ping` or `curl -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 honours `TlsVerifyMode`, the same way `Probe` already does — similar to the `nodeHTTPClientFor` function in `web/service/node.go`.
Author
Owner

@Flylink commented on GitHub (Jun 5, 2026):

ping avg = 40.7 ms
packet loss = 0%
curl time_total = 0.151s

<!-- gh-comment-id:4631652538 --> @Flylink commented on GitHub (Jun 5, 2026): ping avg = 40.7 ms packet loss = 0% curl time_total = 0.151s
Author
Owner

@Flylink commented on GitHub (Jun 5, 2026):

Additional diagnostic result:

From the main server, an unauthenticated request to the same endpoint returns immediately:

curl -vk -m 10 \
https://remote-domain:remote-port/basePath/panel/api/inbounds/list

Result:

HTTP/1.1 404 Not Found

The response is immediate, TLS handshake succeeds, and the remote panel is reachable.

However, the background node sync job still logs:

node traffic sync: fetch from remote-node failed:
GET panel/api/inbounds/list:
context deadline exceeded

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

<!-- gh-comment-id:4634090660 --> @Flylink commented on GitHub (Jun 5, 2026): Additional diagnostic result: From the main server, an unauthenticated request to the same endpoint returns immediately: ```bash curl -vk -m 10 \ https://remote-domain:remote-port/basePath/panel/api/inbounds/list ``` Result: ```text HTTP/1.1 404 Not Found ``` The response is immediate, TLS handshake succeeds, and the remote panel is reachable. However, the background node sync job still logs: ```text node traffic sync: fetch from remote-node failed: GET panel/api/inbounds/list: context deadline exceeded ``` 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
Author
Owner

@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.

<!-- gh-comment-id:4634198312 --> @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.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#3485
No description provided.