[GH-ISSUE #4840] [Bug]: 入站协议从vless+TCP+Reality修改为vless+XHTTP+Reality后,节点无法使用,出现-1 #3372

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

Originally created by @gl1102 on GitHub (Jun 3, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4840

Describe the bug

入站协议从vless+TCP+Reality修改为vless+XHTTP+Reality后,节点无法使用,出现-1
After switching the inbound protocol from VLESS+TCP+Reality to VLESS+XHTTP+Reality, the node fails to work and returns error code -1.

可能原因是因为我在RAW作为传输方式时设置了流控xtls-rprx-vision,而xhttp没有这个选项,所以在原有节点进行修改传输方式时,就会导致节点失效
The root cause is presumed as follows: flow control xtls-rprx-vision was configured under the original RAW transport setting, yet this parameter is unsupported for XHTTP transport. Directly modifying the transport mode on the existing node without removing the invalid option consequently renders the node unusable.

Image Image Image

How to reproduce the problem

新建一个vless+TCP+Reality入站,并设置好用户流控,然后修改入站为vless+XHTTP+Reality后,用户重新订阅后节点失效
Create a new VLESS+TCP+Reality inbound and configure the user's flow control parameters accordingly. After switching the inbound transport to VLESS+XHTTP+Reality and having users resubscribe, the node becomes unavailable.

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

No response

3x-ui version

3.2.6

Xray-core version

No response

How did you install 3x-ui?

Docker / Docker Compose

Operating system

Ubuntu24.02

Which parts of the panel are affected?

Subscription (share links / Clash / JSON)

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 @gl1102 on GitHub (Jun 3, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4840 ### Describe the bug 入站协议从vless+**TCP**+Reality**修改为**vless+**XHTTP**+Reality后,节点无法使用,**出现-1** After switching the inbound protocol from VLESS+TCP+Reality to VLESS+XHTTP+Reality, the node fails to work and returns error code -1. 可能原因是因为我在**RAW**作为传输方式时设置了流控**xtls-rprx-vision**,而xhttp没有这个选项,所以在原有节点进行修改传输方式时,就会导致节点失效 The root cause is presumed as follows: flow control `xtls-rprx-vision` was configured under the original RAW transport setting, yet this parameter is unsupported for XHTTP transport. Directly modifying the transport mode on the existing node without removing the invalid option consequently renders the node unusable. <img width="1175" height="776" alt="Image" src="https://github.com/user-attachments/assets/50791c4b-bae5-4858-8d8e-55d1c3eb0eea" /> <img width="1029" height="1271" alt="Image" src="https://github.com/user-attachments/assets/a3f78d52-4673-4525-930a-e257cd4887f2" /> <img width="1140" height="1347" alt="Image" src="https://github.com/user-attachments/assets/b5a61422-0135-4694-9b71-4e86c278f2f7" /> ### How to reproduce the problem 新建一个vless+**TCP**+Reality入站,并设置好用户流控,然后修改入站为vless+**XHTTP**+Reality后,用户重新订阅后节点失效 Create a new VLESS+TCP+Reality inbound and configure the user's flow control parameters accordingly. After switching the inbound transport to VLESS+XHTTP+Reality and having users resubscribe, the node becomes unavailable. ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.2.6 ### Xray-core version _No response_ ### How did you install 3x-ui? Docker / Docker Compose ### Operating system Ubuntu24.02 ### Which parts of the panel are affected? Subscription (share links / Clash / JSON) ### 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:31:58 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

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

感谢详细的问题描述,根因分析完全正确。已通过代码确认这是一个真实的 bug。

根因(已在代码中确认)

两处关键代码存在缺陷:

1. Xray 运行时配置生成 (web/service/xray.go:149-161)

在为 VLESS 协议生成客户端条目时,只要 flow 字段非空就直接写入配置,不检查当前传输方式是否支持流控:

flow := c.Flow
// ...
case model.VLESS:
    if flow \!= "" {
        entry["flow"] = flow   // ← XHTTP 也会被写入,导致 Xray-core 报错
    }

2. 修改入站时未清理 flow (web/service/inbound.go)

UpdateInbound() 调用了 normalizeStreamSettings() 处理传输协议的设置,但不会在传输方式从 TCP 改为 XHTTP 时自动清除客户端的 flow 字段。

实际上代码中存在 inboundCanEnableTlsFlow() 函数(inbound.go:284),它能正确判断仅 TCP + TLS/Reality 时才允许 flow,但该函数只在"复制客户端到新入站"时被调用,UpdateInbound() 中没有调用它。

结果:修改传输后,客户端数据库记录中的 flow: xtls-rprx-vision 依然存在,被写入 Xray 运行时配置,而 XHTTP 不支持该参数,导致连接失败(返回 -1)。

值得注意的是,订阅链接生成(sub/subService.go:424-431)是正确的——它已经做了 streamNetwork == "tcp" 的判断,所以分享链接本身不会携带 flow。问题出在 Xray-core 的运行时配置侧。


临时解决方案

在修改传输方式为 XHTTP 后,手动清空每个客户端的 Flow 字段:

  1. 面板中打开该入站,点击客户端列表
  2. 对每个客户端点击编辑,将 Flow 下拉框设为空(None/无)
  3. 保存后重启 Xray-core(面板 → 重启 Xray)

正确修复方向

应在以下至少一处添加传输方式兼容性检查:

  • web/service/xray.go:159:在写入 entry["flow"] 前,调用类似 inboundCanEnableTlsFlow() 的判断,若传输方式不支持流控则跳过。
  • web/service/inbound.go(UpdateInbound()):当检测到传输方式由 TCP 改为其他(XHTTP/WS/gRPC 等)时,自动将关联客户端的 flow 字段清空。

欢迎提交 PR 修复此问题。

<!-- gh-comment-id:4608497305 --> @github-actions[bot] commented on GitHub (Jun 3, 2026): 感谢详细的问题描述,根因分析完全正确。已通过代码确认这是一个真实的 bug。 ## 根因(已在代码中确认) **两处关键代码存在缺陷:** **1. Xray 运行时配置生成 (`web/service/xray.go:149-161`)** 在为 VLESS 协议生成客户端条目时,只要 `flow` 字段非空就直接写入配置,**不检查当前传输方式是否支持流控**: ```go flow := c.Flow // ... case model.VLESS: if flow \!= "" { entry["flow"] = flow // ← XHTTP 也会被写入,导致 Xray-core 报错 } ``` **2. 修改入站时未清理 flow (`web/service/inbound.go`)** `UpdateInbound()` 调用了 `normalizeStreamSettings()` 处理传输协议的设置,但**不会在传输方式从 TCP 改为 XHTTP 时自动清除客户端的 `flow` 字段**。 实际上代码中存在 `inboundCanEnableTlsFlow()` 函数(`inbound.go:284`),它能正确判断仅 `TCP + TLS/Reality` 时才允许 flow,但该函数**只在"复制客户端到新入站"时被调用**,`UpdateInbound()` 中没有调用它。 **结果**:修改传输后,客户端数据库记录中的 `flow: xtls-rprx-vision` 依然存在,被写入 Xray 运行时配置,而 XHTTP 不支持该参数,导致连接失败(返回 -1)。 值得注意的是,**订阅链接生成**(`sub/subService.go:424-431`)是正确的——它已经做了 `streamNetwork == "tcp"` 的判断,所以分享链接本身不会携带 `flow`。问题出在 Xray-core 的运行时配置侧。 --- ## 临时解决方案 在修改传输方式为 XHTTP 后,手动清空每个客户端的 Flow 字段: 1. 面板中打开该入站,点击客户端列表 2. 对每个客户端点击编辑,将 **Flow** 下拉框设为空(None/无) 3. 保存后重启 Xray-core(面板 → 重启 Xray) --- ## 正确修复方向 应在以下至少一处添加传输方式兼容性检查: - **`web/service/xray.go:159`**:在写入 `entry["flow"]` 前,调用类似 `inboundCanEnableTlsFlow()` 的判断,若传输方式不支持流控则跳过。 - **`web/service/inbound.go`(`UpdateInbound()`)**:当检测到传输方式由 TCP 改为其他(XHTTP/WS/gRPC 等)时,自动将关联客户端的 `flow` 字段清空。 欢迎提交 PR 修复此问题。
Author
Owner

@MHSanaei commented on GitHub (Jun 3, 2026):

i don't understand anything of this
open issue only english please

<!-- gh-comment-id:4611256821 --> @MHSanaei commented on GitHub (Jun 3, 2026): i don't understand anything of this open issue only english please
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#3372
No description provided.