[GH-ISSUE #5597] [Bug]: Shadowsocks 2022 inbound requires full Xray restart after user renewal (runtime state not updated) #3910

Closed
opened 2026-10-31 20:35:50 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @mori-1997-mori2276-cmd on GitHub (Jun 27, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5597

Describe the bug

When using Shadowsocks 2022 (AEAD) in Xray/x-ui, user updates (renewal / expiry / traffic reset) are not reflected in the running Xray instance unless the service is fully restarted.

This results in inactive sessions for updated users until a restart is performed.

How to reproduce the problem

🔴 Observed Behavior:

  • Updating a Shadowsocks 2022 user does not take effect immediately
  • User remains unable to connect after renewal
  • Requires full Xray restart to activate user

✔️ Expected Behavior:

  • Changes should apply immediately without restart

🟢 Comparison:

  • Shadowsocks 2022 → needs restart
  • VLESS → updates work immediately without restart

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

No response

3x-ui version

3.4.1

Xray-core version

26.6.22

How did you install 3x-ui?

install.sh script

Operating system

24 & 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 @mori-1997-mori2276-cmd on GitHub (Jun 27, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5597 ### Describe the bug When using Shadowsocks 2022 (AEAD) in Xray/x-ui, user updates (renewal / expiry / traffic reset) are not reflected in the running Xray instance unless the service is fully restarted. This results in inactive sessions for updated users until a restart is performed. ### How to reproduce the problem ## 🔴 Observed Behavior: - Updating a Shadowsocks 2022 user does not take effect immediately - User remains unable to connect after renewal - Requires full Xray restart to activate user ## ✔️ Expected Behavior: - Changes should apply immediately without restart ## 🟢 Comparison: - Shadowsocks 2022 → needs restart - VLESS → updates work immediately without restart ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.4.1 ### Xray-core version 26.6.22 ### How did you install 3x-ui? install.sh script ### Operating system 24 & 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:35:50 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@github-actions[bot] commented on GitHub (Jun 27, 2026):

This is a confirmed bug in the current source (v3.4.1). The root cause is in internal/xray/api.go, AddUser(), lines 496–509.

What happens

When AddUser is called for a Shadowsocks inbound, it branches on the cipher string:

switch cipher {
case "aes-256-gcm":
    ssCipherType = shadowsocks.CipherType_AES_256_GCM
case "chacha20-poly1305", "chacha20-ietf-poly1305":
    ssCipherType = shadowsocks.CipherType_CHACHA20_POLY1305
case "xchacha20-poly1305", "xchacha20-ietf-poly1305":
    ssCipherType = shadowsocks.CipherType_XCHACHA20_POLY1305
default:
    ssCipherType = shadowsocks.CipherType_NONE
}

if ssCipherType \!= shadowsocks.CipherType_NONE {
    account = serial.ToTypedMessage(&shadowsocks.Account{...})
} else {
    account = serial.ToTypedMessage(&shadowsocks_2022.ServerConfig{
        Key:   password,
        Email: userEmail,
    })
}

All SS-2022 cipher methods (2022-blake3-aes-128-gcm, 2022-blake3-aes-256-gcm, 2022-blake3-chacha20-poly1305) fall through to default, giving CipherType_NONE, and then the else branch wraps a shadowsocks_2022.ServerConfig as the user account.

shadowsocks_2022.ServerConfig is the inbound-level server configuration, not a per-user credential object. Passing it to AlterInbound with AddUserOperation via gRPC causes the operation to fail or have no effect in Xray-core's SS-2022 handler, because the expected type is a per-user account, not the full server config.

How this maps to the symptom

The update path in internal/web/service/client_inbound_apply.go (UpdateInboundClient, lines 667–699) does:

  1. rt.RemoveUser() to drop the old credential from the running instance — this succeeds.
  2. rt.AddUser() to re-register the updated credential — this fails for SS-2022 due to the wrong account type.
  3. On failure, sets needRestart = true.

needRestart = true causes the controller (internal/web/controller/client.go:173) to call xrayService.SetToNeedRestart(), which a 30-second cron job in internal/web/web.go:315 detects and uses to trigger a full Xray restart. Once restarted, Xray loads the inbound configuration from the database, correctly initializing the SS-2022 inbound with all clients.

The same flaw affects traffic-reset re-enablement (internal/web/service/inbound_traffic.go:571) and adding new clients to an SS-2022 inbound (internal/web/service/client_inbound_apply.go:396).

Why VLESS works immediately

For VLESS, AddUser sends &vless.Account{Id: uuid, Flow: flow}, which is the correct per-user type that Xray-core's VLESS handler accepts via AddUserOperation. The gRPC call succeeds and the user is live in the running instance without any restart.

Current workaround

The auto-restart triggered by SetToNeedRestart() fires within 30 seconds of the update and restores the SS-2022 user. During that window, renewed or reset clients cannot connect because RemoveUser succeeded but AddUser did not. If you need instant availability after a renewal, trigger a manual Xray restart immediately via the panel restart button or x-ui → option 3, rather than waiting for the automatic cycle.

There is no panel setting that prevents this gap; RestartXrayOnClientDisable (in Settings) only applies to automated traffic-limit disablement, not to manual client updates.

Fix location

The fix is confined to internal/xray/api.go AddUser(): for SS-2022 ciphers the code needs to pass the appropriate per-user account type (or, if Xray-core's gRPC handler does not support per-user add for SS-2022, an alternative approach such as full inbound replacement via DelInbound+AddInbound would be required). That determination depends on whether the running xray-core version exposes a compatible AddUser path for SS-2022 inbounds.


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

<!-- gh-comment-id:4814450581 --> @github-actions[bot] commented on GitHub (Jun 27, 2026): This is a confirmed bug in the current source (v3.4.1). The root cause is in `internal/xray/api.go`, `AddUser()`, lines 496–509. **What happens** When `AddUser` is called for a Shadowsocks inbound, it branches on the cipher string: ```go switch cipher { case "aes-256-gcm": ssCipherType = shadowsocks.CipherType_AES_256_GCM case "chacha20-poly1305", "chacha20-ietf-poly1305": ssCipherType = shadowsocks.CipherType_CHACHA20_POLY1305 case "xchacha20-poly1305", "xchacha20-ietf-poly1305": ssCipherType = shadowsocks.CipherType_XCHACHA20_POLY1305 default: ssCipherType = shadowsocks.CipherType_NONE } if ssCipherType \!= shadowsocks.CipherType_NONE { account = serial.ToTypedMessage(&shadowsocks.Account{...}) } else { account = serial.ToTypedMessage(&shadowsocks_2022.ServerConfig{ Key: password, Email: userEmail, }) } ``` All SS-2022 cipher methods (`2022-blake3-aes-128-gcm`, `2022-blake3-aes-256-gcm`, `2022-blake3-chacha20-poly1305`) fall through to `default`, giving `CipherType_NONE`, and then the `else` branch wraps a `shadowsocks_2022.ServerConfig` as the user account. `shadowsocks_2022.ServerConfig` is the **inbound-level server configuration**, not a per-user credential object. Passing it to `AlterInbound` with `AddUserOperation` via gRPC causes the operation to fail or have no effect in Xray-core's SS-2022 handler, because the expected type is a per-user account, not the full server config. **How this maps to the symptom** The update path in `internal/web/service/client_inbound_apply.go` (`UpdateInboundClient`, lines 667–699) does: 1. `rt.RemoveUser()` to drop the old credential from the running instance — this succeeds. 2. `rt.AddUser()` to re-register the updated credential — this fails for SS-2022 due to the wrong account type. 3. On failure, sets `needRestart = true`. `needRestart = true` causes the controller (`internal/web/controller/client.go:173`) to call `xrayService.SetToNeedRestart()`, which a 30-second cron job in `internal/web/web.go:315` detects and uses to trigger a full Xray restart. Once restarted, Xray loads the inbound configuration from the database, correctly initializing the SS-2022 inbound with all clients. The same flaw affects traffic-reset re-enablement (`internal/web/service/inbound_traffic.go:571`) and adding new clients to an SS-2022 inbound (`internal/web/service/client_inbound_apply.go:396`). **Why VLESS works immediately** For VLESS, `AddUser` sends `&vless.Account{Id: uuid, Flow: flow}`, which is the correct per-user type that Xray-core's VLESS handler accepts via `AddUserOperation`. The gRPC call succeeds and the user is live in the running instance without any restart. **Current workaround** The auto-restart triggered by `SetToNeedRestart()` fires within 30 seconds of the update and restores the SS-2022 user. During that window, renewed or reset clients cannot connect because `RemoveUser` succeeded but `AddUser` did not. If you need instant availability after a renewal, trigger a manual Xray restart immediately via the panel restart button or `x-ui` → option 3, rather than waiting for the automatic cycle. There is no panel setting that prevents this gap; `RestartXrayOnClientDisable` (in Settings) only applies to automated traffic-limit disablement, not to manual client updates. **Fix location** The fix is confined to `internal/xray/api.go` `AddUser()`: for SS-2022 ciphers the code needs to pass the appropriate per-user account type (or, if Xray-core's gRPC handler does not support per-user add for SS-2022, an alternative approach such as full inbound replacement via `DelInbound`+`AddInbound` would be required). That determination depends on whether the running xray-core version exposes a compatible `AddUser` path for SS-2022 inbounds. --- *This response was generated automatically; a maintainer may follow up.*
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#3910
No description provided.