mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #6566] [Bug]: Clash subscription update returns no nodes, while direct link import works #4401
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#4401
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 @liangyoufeng on GitHub (Sep 16, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6566
Describe the bug
I used and activated the Clash subscription feature, and then used a custom domain name and certificate to access the subscription link. Scanning or copying the link directly to import nodes is normal, but although scanning and copying subscriptions can be added, updating subscriptions does not return nodes.
View the logs as follows:
Sep 16 15:08:08 aio x-ui[253880]: 2026/09/16 15:08:08 http: TLS handshake error from 14.26.160.166:52509: write tcp 172.25.51.36:12096->14.26.160.166:52509: write: connection reset by peer
I don't know where the configuration went wrong, please assist me
How to reproduce the problem
Expected behavior
No response
Actual behavior
No response
Relevant logs
Screenshots
No response
3x-ui version
v3.8.5
Xray-core version
26.9.9
How did you install 3x-ui?
install.sh script
Operating system
ubuntu24.04
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
@github-actions[bot] commented on GitHub (Sep 16, 2026):
Thanks for the report — I could not confirm a defect from what is in it, and the one log line you pasted points at a different failure than "the Clash profile comes back empty". Below is what I verified in the source, the most likely cause, and the two commands that will tell the two failures apart.
What your log line actually says
That string is not produced by 3x-ui — it does not exist anywhere in the panel source. It comes from Go's
net/http, which the subscription server uses directly (internal/sub/sub.go:401-421), and it is logged when the TLS handshake fails, i.e. before any HTTP request line is read. No subscription handler ran for that connection. A single such line is normally a client or a port scanner closing mid-handshake, and on its own it is not evidence of a subscription bug.One thing that does not line up: you say you set the subscription port to 2096, but the log line is from 12096 (
172.25.51.36:12096). I cannot tell from the report which listener that is. The subscription server is a separate listener from the panel (main.go:125-127, bound tosubPortininternal/sub/sub.go:388-392), and the panel port does not serve/sub/— a subscription URL pointed at the panel port will never return a profile.What I ruled out in the code
Step 3 of your repro ("open routing in Clash/miHomo") cannot empty the profile by itself.
subClashRulesdefaults to""(internal/web/service/setting.go:157) and the merge is guarded:With an empty rules box the toggle is a no-op.
Clash auto-detect is User-Agent based, with the default matcher
(?i)(clash|mihomo)(internal/web/service/setting.go:38). If your client's UA contains neither word,/sub/<id>falls through to the raw branch and returns the base64 link list (internal/sub/controller.go:470-512;subEncryptdefaults to"true"), which a Clash client imports as zero proxies.Accept: text/htmlbeats auto-detect on purpose.wantsHTMLshort-circuitsshouldAutoServeFormat(internal/sub/controller.go:534-539) and is pinned by a test —{name: "browser HTML wins", autoDetect: true, clashEnabled: true, wantsHTML: true, userAgent: "Clash-Verge/v2.4.2"}(internal/sub/controller_test.go:197). A client that sends that header gets the HTML info page, not YAML.Most likely cause, if the HTTPS fetch is in fact succeeding
Auto-detect deliberately does not tell Clash for Windows apart from Mihomo —
ClashforWindows/0.20.39matches the same regex and is served the Mihomo profile (internal/sub/controller_test.go:192). The legacy Clash core cannot parse that profile (novless, Reality, Hysteria2, XHTTP, HTTPUpgrade, SS-2022) and shows no nodes. For that client the endpoint is:which filters down to the proxy types the legacy core supports, and returns an explicit
422instead of an unusable profile when nothing is compatible (internal/sub/controller.go:890-892). Clash Verge Rev / Mihomo / FlClash should use/clash/<sub-id>or/mihomo/<sub-id>. This is documented under Subscription → Output formats.Two checks that settle it
1. Is the subscription server actually on HTTPS?
It prints either
Sub server running HTTPS on …orSub server running HTTP on …(internal/sub/sub.go:402,:405,:408). If it says HTTP, the certificate did not load and theError loading certificates:line just above says why (internal/sub/sub.go:404). Note the subscription server has its own cert settings,subCertFile/subKeyFile— separate from the panel's. Setting only the panel certificate leaves the subscription server on plain HTTP.2. What does the client actually receive?
How to read it:
200+ YAML starting withproxies:200+ one long base64 blob200+<!doctype html>Accept: text/html404internal/sub/controller.go:37-43)403internal/web/middleware/domainValidator.go:24-27)What I still need
I cannot run the panel or open images here, so please paste text rather than screenshots.
Verdict: Insufficient information
Severity: N/A
Confidence: Medium
Root cause: None established. The reported symptom has at least three distinct causes that the report cannot distinguish: the HTTPS fetch never completing (what the pasted
net/httphandshake line shows), the raw base64 body being served because the User-Agent misses(?i)(clash|mihomo)(internal/sub/controller.go:470-512), and a Mihomo-dialect profile served to a legacy Clash for Windows client (internal/sub/controller_test.go:192+docs/content/docs/en/config/subscription.mdx:72-75).Already fixed: Not applicable — v3.8.5 is the current release (
gh release list), and nothing in this path changed between v3.8.0 and HEAD excepte26cf1d3, which touches onlysubPageContext(internal/sub/controller.go:661-687), not the subscription body.Duplicate of: None
Evidence:
internal/web/service/setting.go:157"subClashRules": ""andinternal/sub/clash_service.go:161-171(if resolveErr == nil && strings.TrimSpace(resolved) != "") — the Clash routing toggle is a no-op with an empty rules field;internal/web/service/setting.go:38DefaultSubClashUserAgentRegex = (?i)(clash|mihomo);internal/sub/controller.go:534-539if !autoDetect || !formatEnabled || wantsHTML || userAgentRegex == nil { return false }withinternal/sub/controller_test.go:197pinning "browser HTML wins";internal/sub/controller_test.go:192pinningClashforWindows/0.20.39→ Mihomo profile;internal/sub/sub.go:394-409(sub server TLS is driven bysubCertFile/subKeyFileonly, falling back to plain HTTP withError loading certificates:on a load failure);main.go:125-127(subscription server is a separate listener from the panel); no occurrence of the literalTLS handshake erroranywhere in the Go source.Not determined: Whether the Clash client ever gets an HTTP 200 at all. Check 2 above (
curlwith a mihomo User-Agent against the subscription URL) settles it in one command.This reply was generated automatically; a maintainer may follow up.
@liangyoufeng commented on GitHub (Sep 16, 2026):
root@aio:~# journalctl -u x-ui --no-pager | grep -iE "Sub server running|Error loading certificates"
Sep 16 14:59:24 aio /usr/local/x-ui/x-ui[253880]: INFO - Sub server running HTTPS on [::]:12096
root@aio:~# curl -vk https://127.0.0.1:12096/xxx/xxx 2>&1 | head -30
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 127.0.0.1:12096...
} [5 bytes data]
} [512 bytes data]
{ [122 bytes data]
{ [6 bytes data]
{ [3420 bytes data]
{ [79 bytes data]
{ [36 bytes data]
} [1 bytes data]
} [36 bytes data]
@liangyoufeng commented on GitHub (Sep 16, 2026):
root@aio:~# curl -sv -o /tmp/sub.out -w 'status=%{http_code}\n'
-H 'User-Agent: mihomo/1.19.12'
'https://xxx.net:12096/xxx/xxx'
head -c 300 /tmp/sub.out
} [5 bytes data]
} [512 bytes data]
{ [5 bytes data]
{ [122 bytes data]
{ [10 bytes data]
{ [3420 bytes data]
{ [80 bytes data]
{ [36 bytes data]
} [1 bytes data]
} [36 bytes data]
} [5 bytes data]
{ [5 bytes data]
{ [122 bytes data]
< HTTP/1.1 200 OK
< Content-Length: 465
< Content-Type: application/yaml; charset=utf-8
< Profile-Update-Interval: 12
< Subscription-Userinfo: upload=10230; download=47621; total=0; expire=0
< Date: Wed, 16 Sep 2026 08:36:03 GMT
<
{ [465 bytes data]
status=200
proxies:
name: vless-test
network: tcp
port: 16509
reality-opts:
public-key: xxxxUozA
short-id: xxx012
support-x25519mlkem768: true
server: xxx.net
servername: aws.amazon.com
tls: true
@github-actions[bot] commented on GitHub (Sep 16, 2026):
Thanks — those two outputs clear the panel side. The subscription server is up on HTTPS, the certificate loaded, and it completes a full TLS 1.3 handshake. So the remaining question is no longer "is the panel misconfigured" but "does your client's request ever reach it, and what does it get back" — and there is one log switch that answers both in a single line.
What your output proves
INFO - Sub server running HTTPS on [::]:12096is only printed on the branch wheretls.LoadX509KeyPairsucceeded (internal/sub/sub.go:394-402); the failure branch printsError loading certificates:+running HTTP. Your certificate is fine.%{level} - %{message}(internal/logger/logger.go:133-138) — that is theINFO -prefix above. Yourhttp: TLS handshake error …line has no level prefix, because it comes from Go'snet/http, not from panel code.ALPN: server did not agree on a protocol. Uses default.is expected and harmless: the TLS config sets onlyCertificatesand noNextProtos(internal/sub/sub.go:397-399), so no ALPN is negotiated and the server speaks HTTP/1.1. Every HTTP client falls back to that.What it does not prove (two gaps in that curl)
head -30cut the output before the HTTP status line, so we still do not know what the server answered.https://127.0.0.1:12096/...sendsHost: 127.0.0.1. If you have Subscription domain set in the panel, that request is rejected before any handler runs:So a 403 from that command would mean nothing is wrong. Use
--resolve(curl -sk --resolve YOUR.DOMAIN:12096:127.0.0.1 -o /tmp/s.out -w '%{http_code}\n' https://YOUR.DOMAIN:12096/PATH/SUBID) if you repeat it.Also note the port: your report says 2096, the server says 12096. The URL your clients hold must carry the port the server actually listens on.
There is no subscription-specific TLS path
internal/sub/sub.go:394-402andinternal/web/web.go:620-637build the listener identically — sametls.Config{Certificates: []tls.Certificate{cert}}, samenetwork.NewAutoHttpsListener, sametls.NewListener. If the panel is reachable over HTTPS from the outside and the subscription port is not, the difference is the network path or the port, not panel code.The one check that settles it
Every request to the
<subPath>/<subid>endpoint logs which format branch served it and the client's real User-Agent:The branch is one of
info/html/clash/json/raw(internal/sub/controller.go:456-480). It is a DEBUG line, so:XUI_LOG_LEVEL=debugto/etc/default/x-ui— that is the file the unit reads on Ubuntu (x-ui.service.debian:9,EnvironmentFile=-/etc/default/x-ui). Write it exactly lowercasedebug: any other value hitslog.Fatalf("Unknown log level: %v", …)(main.go:89) and the service will not start.systemctl restart x-uiHow to read the result:
:12096, which is what yourTLS handshake errorline shows. Not a panel problem.branch=clash/clash-legacy/<subid>, which returns an explicit422rather than an unusable profile (internal/sub/controller.go:889-892).branch=rawbranch=htmlAccept: text/html, which short-circuits auto-detect on purpose (internal/sub/controller.go:534-539). Use the explicit/clash/<subid>URL.Set the value back to
info(or remove the line) once you are done.Note the log line is emitted for the
<subPath>/<subid>endpoint; if you point the client at the explicit/clash/<subid>URL there is no branch line, so run the test with the plain subscription URL first.One inference, not a source fact: the server writes ServerHello plus a 3420-byte certificate chain, your peer sent RST in the middle of that write, and your server's local address
172.25.51.36is private — so the box sits behind NAT. TCP clearly reaches the port (the handshake started), so the forward is fine; something on the path, or the client app's own abort, kills it mid-flight. Since your nodes work, it is worth telling the client to fetch the subscription through the proxy and seeing whether the update then succeeds.What I still need
Subscription request routed:line(s) from the debug log above — please leave theuser_agent=value intact, it is the deciding field.branch=clashand the client still shows nothing: the protocol / transport / security of the test inbound (for example VLESS + TCP + Reality).Verdict: Insufficient information
Severity: N/A
Confidence: Medium
Root cause: Still not established, but the panel side is now ruled out by your own output: the HTTPS branch of
internal/sub/sub.go:394-402is the one that ran, and the handshake completes locally with a valid certificate. The two surviving candidates are (a) the client's request never completing over the network — the peer RST inhttp: TLS handshake error, a string that exists nowhere in this repo — and (b) the client receiving a body it cannot use (raw/htmlbranch,internal/sub/controller.go:456-480).Already fixed: Not applicable — nothing in this path has changed since v3.8.5;
internal/sub/sub.gowas last touched by1d85ef13(profile page URL disclosure), which does not affect the listener.Duplicate of: None
Evidence:
internal/sub/sub.go:394-402(HTTPS log line only on a successfultls.LoadX509KeyPair;tls.ConfigsetsCertificatesonly, hence no ALPN);internal/web/web.go:620-637(byte-for-byte the same listener construction as the subscription server, so there is no sub-specific TLS path);internal/logger/logger.go:133-138format = '%{level} - %{message}'(proves the handshake line is stdlibnet/http, not panel code);internal/web/middleware/domainValidator.go:24-27if host != domain { c.AbortWithStatus(http.StatusForbidden) }(a127.0.0.1Host is rejected when Subscription domain is set);internal/sub/controller.go:541-542logger.Debugf("Subscription request routed: branch=%s user_agent=%q", …)with the five call sites at:460,:464,:472,:477,:480;internal/web/service/setting.go:38DefaultSubClashUserAgentRegex = '(?i)(clash|mihomo)';internal/sub/controller.go:889-892(errNoLegacyClashProxies→http.StatusUnprocessableEntity);main.go:77-89(config.GetLogLevel()driveslogger.InitLogger,default:islog.Fatalf);x-ui.service.debian:9EnvironmentFile=-/etc/default/x-ui.Not determined: Whether the client's subscription request reaches the panel at all. The
XUI_LOG_LEVEL=debug+Subscription request routedcheck above settles it with one line — its presence or absence splits the two remaining candidates cleanly.This reply was generated automatically; a maintainer may follow up.
@github-actions[bot] commented on GitHub (Sep 16, 2026):
Your own output settles it: the panel is serving the Clash subscription correctly. The request returned
200,Content-Type: application/yaml, and a real Mihomo profile containing yourvless-testnode. There is no defect on the panel side — the failure is between your client and port12096, or inside the client app.What your paste proves
Auto-detect fired and the Clash branch served the response.
application/yaml; charset=utf-8is set only on the Clash branch (internal/sub/controller.go:914), so yourmihomo/1.19.12User-Agent matched(?i)(clash|mihomo)(internal/web/service/setting.go:38) and the server did not fall through to the raw base64 or HTML branch.The profile you received is complete, not truncated-empty. Your
head -c 300cut the body at 300 of 465 bytes, but the generator is unconditional — every Clash response is built from this map:Keys are emitted alphabetically — visible in your own output, where the node's keys run
client-fingerprint,name,network,port,reality-opts,server,servername,tls— soproxy-groups:andrules:sort after theproxies:block and sit in the 165 bytes yourhead -c 300discarded. An empty profile is impossible on this path anyway:getClashreturns an empty string when there is nothing to serve (internal/sub/clash_service.go:99-101,132-134), the handler then takesreturn falseatcontroller.go:897-899, andwriteSubError(c, nil)setsc.Status(http.StatusNotFound)(internal/sub/controller.go:37-41). You would have gotten a404, not a200.Subscription-Userinfo: upload=10230; download=47621shows the node itself has carried traffic. That matches your report that direct link import works.So what is failing
The only failure signal anywhere in this thread is still the line from your first post:
That string does not exist anywhere in this repository — it is Go's
net/http, logged when the TLS handshake dies before any request line is read. Yourcurlran on the server itself (root@aio:~#), so it exercised the loopback/hairpin path, not the path from14.26.160.166. The two are not the same test.Why one works and the other does not, stated as an inference rather than a source fact: your nodes are REALITY on port 16509 masquerading as
aws.amazon.com, which is designed to survive exactly this. Your subscription fetch is ordinary TLS to your own domain on a non-standard port12096, presenting a 4-level Let's Encrypt chain that your own trace shows is 3420 bytes. Your server's local address172.25.51.36is private, so the box sits behind NAT. A peer RST arriving while the server is writing that large certificate flight is the signature of either path interference or a PMTU black hole — not of panel code.internal/sub/sub.go:394-402andinternal/web/web.go:620-637build the two listeners identically, so there is no subscription-specific TLS behaviour to blame.What to do
curlfrom the client's device, not from the server. That is the test that has not been done yet. If it fails there and succeeds on the server, the panel is out of the picture.443, or front it with a reverse proxy and set Subscription URL (subURI) so the links the panel hands out point at the public address — see Panel settings and Subscription.reality-opts.support-x25519mlkem768: true(internal/sub/clash_service.go:1135), and the constraints around it are written up at REALITY → Mihomo and ML-KEM.Two housekeeping notes. Your report said port 2096; the server and both traces say 12096 — the URL your clients hold must carry
12096. And the> GET /…request line in your last paste was not redacted, so your real subscription path and subscription ID are now public in this thread; rotate the client's subscription ID and change the subscription path in the panel.I am closing this as a configuration/network issue rather than a panel defect. If you run the
XUI_LOG_LEVEL=debugcheck from my previous comment and theSubscription request routed: branch=…line showsbranch=raworbranch=htmlfor your real client, comment here with that line and it can be looked at again — that would be the one outcome that points back at the panel.Verdict: Not a bug (user configuration)
Severity: N/A
Confidence: High that there is no panel-side defect (proven by the reporter's own 200 response plus the source below); the network-path diagnosis is explicitly labelled an inference.
Root cause: None in 3x-ui. The subscription server returns a complete, valid Mihomo profile for this subscription ID — confirmed end to end by the reporter's own
curl(status=200,application/yaml; charset=utf-8, body beginningproxies:). The remaining failure is the TLS handshake being reset by the peer before any request line is read, which happens in Go'snet/httpbelow all panel code.Already fixed: Not applicable — v3.8.5 is the current release (
gh release list), and no defect was found to fix.Duplicate of: None —
gh search issues --repo MHSanaei/3x-ui "clash subscription no nodes","subscription update no nodes"and"TLS handshake error subscription"all returned no candidates.Evidence:
internal/sub/controller.go:914c.Data(200, "application/yaml; charset=utf-8", []byte(clashSub))— that content type is emitted only by the Clash branch, so auto-detect fired for the reporter's UA;internal/sub/clash_service.go:149-157(proxies+proxy-groups+rulesbuilt unconditionally, so a200on this path is never an empty profile) withinternal/sub/clash_service.go:99-101and:132-134returning an empty body — hence a404— when there is nothing to serve;internal/web/service/setting.go:38DefaultSubClashUserAgentRegex = '(?i)(clash|mihomo)';internal/sub/sub.go:394-402vsinternal/web/web.go:620-637(identical listener construction, no sub-specific TLS path);internal/sub/clash_service.go:1135realityOpts["support-x25519mlkem768"] = truewithdocs/content/docs/en/config/reality.mdx:126-135; no occurrence of the literalTLS handshake erroranywhere in the Go source, confirming that line is stdlibnet/http.Not determined: Whether the remote client's request reaches
:12096at all. The reporter'scurlran on the server itself, so it does not test the external path; repeating it from the client's own device settles it in one command.I also made the title more specific — it was "[Bug]: Subscription cannot be used", which did not say which part failed.
This reply was generated automatically; a maintainer may follow up.