[GH-ISSUE #5713] [Bug]: connection drop after 5 minutes when user its not using #3977

Closed
opened 2026-10-31 20:36:17 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @usamirali on GitHub (Jul 1, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5713

Describe the bug

my protocol is hysteria2 tls and trojan tcp tls

i change the the xray disable user after 300 seconds to 30000 seconds
and keepalive to 10 seconds

but when user not using for 5 minutes or 10
connection goes drop and user needs to restart the connection

How to reproduce the problem

1.when user connection is on and user is working its so good
2.when user dont use connection going to lost after 5 minutes
3.i change the xray difualt drop connection to 30000 and keepalive to 10 seconds but it didnt work

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

No response

3x-ui version

3.4.2

Xray-core version

26.6.27

How did you install 3x-ui?

install.sh script

Operating system

ubuntu 26

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 @usamirali on GitHub (Jul 1, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5713 ### Describe the bug my protocol is hysteria2 tls and trojan tcp tls i change the the xray disable user after 300 seconds to 30000 seconds and keepalive to 10 seconds but when user not using for 5 minutes or 10 connection goes drop and user needs to restart the connection ### How to reproduce the problem 1.when user connection is on and user is working its so good 2.when user dont use connection going to lost after 5 minutes 3.i change the xray difualt drop connection to 30000 and keepalive to 10 seconds but it didnt work ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.4.2 ### Xray-core version 26.6.27 ### How did you install 3x-ui? install.sh script ### Operating system ubuntu 26 ### 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:36:17 +07:00
Author
Owner

@github-actions[bot] commented on GitHub (Jul 1, 2026):

The two protocols have different, separate causes here, both confirmed in the xray-core / 3x-ui source.

Hysteria2

The idle timeout for Hysteria2 is streamSettings.hysteriaSettings.udpIdleTimeout on the inbound itself, not a global "300 seconds" setting. xray-core hard-enforces this between 2 and 600 seconds — a value outside that range makes xray-core refuse to start the config (we've seen the exact rejection, UdpIdleTimeout must be between 2 and 600, in a prior report, #5117). On the version you're running (v3.4.2), the panel's own input for this field is capped at 600 (frontend/src/pages/inbounds/form/protocols/hysteria.tsx), so 30000 cannot actually be saved there — the real ceiling is 600 seconds (10 minutes), which matches what you're observing. There is no server-side setting in 3x-ui or xray-core that lets an idle Hysteria2 session live longer than that; the only way to keep one alive past 10 minutes of true inactivity is for the client app to send its own periodic traffic (keepalive/heartbeat) within that window.

Trojan (TCP)

The "disable after 300 seconds" behavior you're describing is xray's connection policy connIdle (default 300s), set at Xray Configs → Connection Limits → Idle Timeout. Unlike the Hysteria2 field, this one has no upper bound in the panel, so raising it to 30000 should be accepted, and it takes effect immediately (saving that page automatically restarts Xray if it's running). If Trojan is still dropping at ~5 minutes after that change, connIdle likely isn't the cause. Please check:

  1. That 30000 was actually saved under Xray Configs → Connection Limits, and that no error toast appeared when saving (you can confirm the current value in the raw JSON via the same page — look for policy.levels["0"].connIdle).
  2. What exactly the "keepalive" field you changed to 10 was. If it's the inbound's Sockopt → TCP Keep Alive Interval, that only sets the gap between keepalive probes — it has no effect unless TCP Keep Alive Idle (the wait before the first probe) is also set. Left at its default of 0, xray-core omits the option entirely and the OS default idle time applies instead, so no probe would be sent inside a 5-minute window at all. Both fields need to be set together.
  3. Whether something between client and server (mobile carrier NAT, home router, etc.) is closing idle TCP sessions independently of Xray. You noted no reverse proxy/CDN, but a network-level NAT timeout is still worth ruling out.

To narrow this down further, could you share:

  • The policy section of Xray Configs (raw JSON view) so we can confirm connIdle was actually persisted at 30000.
  • Xray logs from the moment of a drop (panel Logs page, or journalctl -u x-ui --since "10 minutes ago" on the server).
  • Which client app you use for Hysteria2/Trojan, and whether the drop happens on Wi-Fi, cellular, or both.

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:4853651274 --> @github-actions[bot] commented on GitHub (Jul 1, 2026): The two protocols have different, separate causes here, both confirmed in the xray-core / 3x-ui source. **Hysteria2** The idle timeout for Hysteria2 is `streamSettings.hysteriaSettings.udpIdleTimeout` on the inbound itself, not a global "300 seconds" setting. xray-core hard-enforces this between **2 and 600 seconds** — a value outside that range makes xray-core refuse to start the config (we've seen the exact rejection, `UdpIdleTimeout must be between 2 and 600`, in a prior report, #5117). On the version you're running (v3.4.2), the panel's own input for this field is capped at 600 (`frontend/src/pages/inbounds/form/protocols/hysteria.tsx`), so `30000` cannot actually be saved there — the real ceiling is 600 seconds (10 minutes), which matches what you're observing. There is no server-side setting in 3x-ui or xray-core that lets an idle Hysteria2 session live longer than that; the only way to keep one alive past 10 minutes of true inactivity is for the client app to send its own periodic traffic (keepalive/heartbeat) within that window. **Trojan (TCP)** The "disable after 300 seconds" behavior you're describing is xray's connection policy `connIdle` (default 300s), set at **Xray Configs → Connection Limits → Idle Timeout**. Unlike the Hysteria2 field, this one has no upper bound in the panel, so raising it to 30000 should be accepted, and it takes effect immediately (saving that page automatically restarts Xray if it's running). If Trojan is still dropping at ~5 minutes after that change, `connIdle` likely isn't the cause. Please check: 1. That `30000` was actually saved under **Xray Configs → Connection Limits**, and that no error toast appeared when saving (you can confirm the current value in the raw JSON via the same page — look for `policy.levels["0"].connIdle`). 2. What exactly the "keepalive" field you changed to 10 was. If it's the inbound's **Sockopt → TCP Keep Alive Interval**, that only sets the gap *between* keepalive probes — it has no effect unless **TCP Keep Alive Idle** (the wait before the *first* probe) is also set. Left at its default of 0, xray-core omits the option entirely and the OS default idle time applies instead, so no probe would be sent inside a 5-minute window at all. Both fields need to be set together. 3. Whether something between client and server (mobile carrier NAT, home router, etc.) is closing idle TCP sessions independently of Xray. You noted no reverse proxy/CDN, but a network-level NAT timeout is still worth ruling out. To narrow this down further, could you share: - The `policy` section of Xray Configs (raw JSON view) so we can confirm `connIdle` was actually persisted at 30000. - Xray logs from the moment of a drop (panel **Logs** page, or `journalctl -u x-ui --since "10 minutes ago"` on the server). - Which client app you use for Hysteria2/Trojan, and whether the drop happens on Wi-Fi, cellular, or both. *This reply was generated automatically; a maintainer may follow up.*
Author
Owner

@MHSanaei commented on GitHub (Jul 2, 2026):

Closing — this is not a panel bug. For Hysteria2, xray-core hard-caps the idle timeout (udpIdleTimeout) at 600 seconds, so an idle session cannot be kept alive past 10 minutes server-side; the client app needs to send its own keepalive traffic. For Trojan, the drop is governed by the connIdle policy and TCP keepalive sockopts (both Idle and Interval must be set together), or by a NAT/router timeout between you and the server — see the detailed guidance above. If you can show connIdle=30000 persisted in the raw policy JSON and drops still occurring at exactly 5 minutes with the Xray log from the moment of a drop, please reopen.

<!-- gh-comment-id:4863449110 --> @MHSanaei commented on GitHub (Jul 2, 2026): Closing — this is not a panel bug. For Hysteria2, xray-core hard-caps the idle timeout (udpIdleTimeout) at 600 seconds, so an idle session cannot be kept alive past 10 minutes server-side; the client app needs to send its own keepalive traffic. For Trojan, the drop is governed by the connIdle policy and TCP keepalive sockopts (both Idle and Interval must be set together), or by a NAT/router timeout between you and the server — see the detailed guidance above. If you can show connIdle=30000 persisted in the raw policy JSON and drops still occurring at exactly 5 minutes with the Xray log from the moment of a drop, please reopen.
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#3977
No description provided.