[GH-ISSUE #4678] [Bug]: Shadowsocks TCP RAW inbound accumulates thousands of CLOSE-WAIT / LAST-ACK sockets under load, causing traffic drop #3228

Closed
opened 2026-10-31 20:30:56 +07:00 by bsakaguchi · 0 comments
Owner

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

System-level socket state examples:

ss -Hant sport = :443 | awk '{print $1}' | sort | uniq -c

Observed output during failure:

5047 CLOSE-WAIT
2080 ESTAB
145 FIN-WAIT-1
1 FIN-WAIT-2
4207 LAST-ACK
1 LISTEN
277 SYN-RECV
35 TIME-WAIT

Observed Xray CPU usage during the issue:

PID    COMMAND           CPU
2997   xray-linux-amd64  1038%

System limits were increased and verified:

Max open files            1048576              1048576              files

nf_conntrack was also increased:

net.netfilter.nf_conntrack_max = 1048576

The issue still appeared before active socket cleanup/restart.

A temporary watchdog was used to mitigate the issue:

ss -K state close-wait sport = :443
ss -K state last-ack sport = :443

This is only a workaround and should not be required for stable production usage.

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

  • 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 @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 ```shell System-level socket state examples: ss -Hant sport = :443 | awk '{print $1}' | sort | uniq -c Observed output during failure: 5047 CLOSE-WAIT 2080 ESTAB 145 FIN-WAIT-1 1 FIN-WAIT-2 4207 LAST-ACK 1 LISTEN 277 SYN-RECV 35 TIME-WAIT Observed Xray CPU usage during the issue: PID COMMAND CPU 2997 xray-linux-amd64 1038% System limits were increased and verified: Max open files 1048576 1048576 files nf_conntrack was also increased: net.netfilter.nf_conntrack_max = 1048576 The issue still appeared before active socket cleanup/restart. A temporary watchdog was used to mitigate the issue: ss -K state close-wait sport = :443 ss -K state last-ack sport = :443 This is only a workaround and should not be required for stable production usage. ``` ### 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 - [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:30:56 +07:00
  • closed this issue
  • added the
    bug
    label
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#3228
No description provided.