mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #6782] [Bug]: VLESS/VMess + WebSocket + TLS inbound with the default ALPN (h2, http/1.1) can't be used: Xray negotiates h2 and the WebSocket dial fails #4518
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#4518
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 @jayhemnani9910 on GitHub (Oct 10, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6782
Describe the bug
On the inbound form, switching Security to TLS fills ALPN with
h2, http/1.1for every transport (createTlsSettingsWithDefaultCert,frontend/src/pages/inbounds/form/useSecurityActions.ts:347→TlsStreamSettingsSchemadefault,frontend/src/schemas/protocols/security/tls.ts:106). The panel copies that ALPN into the server's Xray config, the share link (alpn=h2%2Chttp%2F1.1) and the JSON subscription.With WebSocket as the transport, this combination fails. The client offers
h2, http/1.1, Xray on the server picksh2, and the client's WebSocket handshake then fails. The same inbound works once ALPN is justhttp/1.1. HTTPUpgrade + TLS with the same default ALPN connects fine, so the problem is limited to WebSocket.An Xray-core maintainer describes the same behavior in XTLS/Xray-core#6128: with Xray as the server,
h2, http/1.1negotiates h2 and WS cannot work. So Xray treats it as a config problem. But the panel produces this config by default.How to reproduce the problem
/ws), Security TLS with a certificate. Keep the default ALPN (h2,http/1.1).The same thing happens with VMess + WS + TLS.
Expected behavior
A WebSocket + TLS inbound made with the panel defaults should connect.
Actual behavior
The connection fails. Client log:
What I tested, with the server inbound ALPN left at
h2, http/1.1:HTTPUpgrade + TLS with ALPN
h2, http/1.1: works.Relevant logs
(see Actual behavior)
3x-ui version
3.9.0 (also checked on main at
442b7fb)Xray-core version
26.9.30
How did you install 3x-ui?
Other: release tarball run locally
Operating system
Ubuntu 26.04 (x86_64)
Which parts of the panel are affected?
Xray config generation
Is the panel behind a reverse proxy or CDN?
No, direct access
Additional note
There is a precedent in #4076 (
292eb992, "set ALPN to h3 when switching to Hysteria protocol"): the form could do the same for WebSocket and set ALPN tohttp/1.1when the transport is WebSocket and Security is TLS. That would not fix existing inbounds, which already storeh2, http/1.1. The other option is to droph2for WebSocket when the server config and the links are generated. Which way to go is your call.@github-actions[bot] commented on GitHub (Oct 10, 2026):
This is a real panel-side bug. When you switch Security to TLS, every inbound gets ALPN
h2, http/1.1, whatever its transport. Nothing on the server-config, share-link or subscription path dropsh2for WebSocket, so a WS + TLS inbound made with the defaults sends Xray and clients the exact combination your log shows failing. It is still present on the default branch.Workaround: in the inbound's TLS section, set ALPN to
http/1.1only, or clear it. Then re-import the link or refresh the subscription. The client keeps whatever ALPN it got from the old link until it does.How the default reaches the client (everything below is checked in the source):
frontend/src/schemas/protocols/security/tls.ts:106sets the default, which applies to every transport:onSecurityChangeuses it with no check on the transport (frontend/src/pages/inbounds/form/useSecurityActions.ts:346-347): The only exception is Hysteria, increateHysteriaTlsSettingsWithDefaultCert(frontend/src/lib/xray/inbound-tls-defaults.ts:31:tls.alpn = ['h3'];). There is nothing similar forws.Inbound.GenXrayInboundConfig(internal/database/model/model.go:375-383) only strips XHTTP client fields and heals Hysteria. It passestlsSettings.alpnto Xray unchanged.params["alpn"] = strings.Join(inst.ALPN, ",")(internal/sub/service.go:877), the per-protocol TLS param builders (internal/sub/service.go:1433-1441,1834-1842,1869-1877), andtlsData["alpn"] = tData["alpn"]in the JSON subscription (internal/sub/json_service.go:771).frontend/src/test/golden/fixtures/inbound-full/vless-ws-tls.json:68andtrojan-ws-tls.json:65both contain"alpn": ["h2", "http/1.1"].I did not check the Xray-core side, because Xray's websocket source is not in this repository. That covers Xray picking
h2and the WS dialer then rejecting it. The evidence for it is your log (websocket: protocol "h2" was given but is not supported) and the upstream issue you linked (XTLS/Xray-core#6128).Verdict: Confirmed bug
Severity: High
Confidence: Medium
Root cause:
TlsStreamSettingsSchema(frontend/src/schemas/protocols/security/tls.ts:106) defaults ALPN to['h2','http/1.1']for every transport, andonSecurityChange(frontend/src/pages/inbounds/form/useSecurityActions.ts:347) applies it towsinbounds too. No later layer (Xray config generation inmodel.go:375, link/subscription builders ininternal/sub/) removesh2for WebSocket. The default dates back tob639a1bb("alpn set by default", 2023-04-14, thenweb/assets/js/model/xray.js) and was carried into the Zod schema by3f787ae1(#4599).Already fixed: No. Still present on the default branch (
442b7fb1) and in v3.9.0.Duplicate of: None. #5473 is about ALPN missing from subscriptions, a different cause.
Evidence:
tls.ts:106,useSecurityActions.ts:346-347,inbound-tls-defaults.ts:31(Hysteria-only override),model.go:375-383,service.go:877,json_service.go:771, golden fixturesvless-ws-tls.json:68andtrojan-ws-tls.json:65.Not determined: Whether Xray-core's WS listener, rather than the client's TLS fingerprint, is what picks
h2. This rests on your log and XTLS/Xray-core#6128 and is not verified here. A WS + TLS test against the current Xray with server ALPNh2,http/1.1would settle it. I also did not check whether Trojan + WS behaves the same, though its fixture stores the same ALPN.Suggested fix: Changing the form default only (as #4076 did for Hysteria) would leave existing WS inbounds broken, as you note. A more complete fix also removes
h2from awsinbound's ALPN whereGenXrayInboundConfigbuilds the server config and whereinternal/subbuilds links and subscriptions, plus the matching link builders infrontend/src/lib/xray/anddocs/lib/xray/. A DB migration that rewrites stored ALPN would be an alternative, but it changes users' saved data, so the maintainer has to decide between the two.@MHSanaei: confirmed High-severity default-configuration bug, see the root cause above.
This reply was generated automatically; a maintainer may follow up.