mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #4678] [Bug]: Shadowsocks TCP RAW inbound accumulates thousands of CLOSE-WAIT / LAST-ACK sockets under load, causing traffic drop #3228
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#3228
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 @AD2L7ER on GitHub (May 30, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4678
Describe the bug
Describe the bug:
I am experiencing a reproducible runtime issue with a Shadowsocks inbound created and managed by 3x-ui.
When using Shadowsocks with TCP RAW transmission on port 443 under high concurrent load, Xray starts accumulating a very large number of half-closed TCP sockets, mainly in CLOSE-WAIT and LAST-ACK states. After this happens, new clients can still establish a connection, but traffic does not pass correctly or stalls until the number of active/stale sockets decreases.
The same server and similar user load do not show the same behavior when using VLESS over WebSocket. The issue appears to be specific to Shadowsocks TCP RAW.
This looks like a TCP connection lifecycle / socket cleanup issue in the Shadowsocks RAW TCP inbound path, or possibly in how 3x-ui generates/manages this inbound configuration for Xray.
I understand this may ultimately belong to Xray-core, but I am reporting it here first because the inbound is created and managed through 3x-ui.
How to reproduce the problem
Install 3x-ui using the official install.sh script.
Create a new inbound with the following settings:
Protocol: Shadowsocks
Port: 443
Network: TCP, UDP
Transmission: TCP RAW
Encryption: AES-256-GCM
Security: none
Add a large number of clients to this inbound.
Allow many users, especially mobile/NAT users, to connect concurrently.
Monitor TCP socket states on the inbound port:
ss -Hant sport = :443 | awk '{print $1}' | sort | uniq -c
After concurrent usage increases, observe that CLOSE-WAIT and LAST-ACK sockets start growing rapidly.
Eventually, new clients can connect, but traffic stalls or is dropped.
Compare with VLESS over WebSocket under similar usage. The same level of CLOSE-WAIT / LAST-ACK accumulation does not occur there.
Expected behavior
Shadowsocks TCP RAW inbound should release TCP sessions properly when clients disconnect, half-close, timeout, or disappear behind unstable mobile/NAT networks.
Xray should not accumulate thousands of CLOSE-WAIT or LAST-ACK sockets on the inbound port.
New clients should continue to pass traffic normally even when many users are connected concurrently.
Actual behavior
Under load, the Shadowsocks TCP RAW inbound accumulates thousands of half-closed TCP sockets.
Example observed socket states:
CLOSE-WAIT: 5047
ESTAB: 2080
LAST-ACK: 4207
SYN-RECV: 277
Another observed case:
CLOSE-WAIT: 4148
ESTAB: 2065
LAST-ACK: 1713
SYN-RECV: 629
When this happens, Xray CPU usage increases significantly and new clients may connect but cannot reliably pass traffic.
After manually killing stale sockets or restarting x-ui/Xray, the service temporarily improves. However, the issue returns again under load.
Manual cleanup command used as temporary workaround:
ss -K state close-wait sport = :443
ss -K state last-ack sport = :443
After cleanup/restart, socket states temporarily return to normal, for example:
CLOSE-WAIT: 42
ESTAB: 1697
LAST-ACK: 40
SYN-RECV: 36
TIME-WAIT: 928
This confirms that the traffic drop correlates with accumulation of stale or half-closed TCP sockets.
Relevant logs
Screenshots
No response
3x-ui version
3.1.0
Xray-core version
26.2.6
How did you install 3x-ui?
install.sh script
Operating system
Ubuntu 22.04 LTS
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