mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[GH-ISSUE #6323] [Bug]: AmneziaWG session goes silent ~1s after the handshake — server stops receiving from the peer, every server-initiated rekey fails (no TCP ever completes) #4295
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#4295
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 @bharmalej on GitHub (Aug 25, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6323
Describe the bug
On v3.7.0 with the new native AmneziaWG inbound, a peer completes the handshake and shows online in the panel, DNS resolves through the tunnel, but no website ever loads.
The embedded
amneziawgnetdevice relays UDP into its loopback SOCKS5 bridge correctly, but TCP essentially never gets relayed.Hard numbers from Xray's
access.logon the same instance, same routing rules, same time window:accepted tcp:accepted udp:in-40188-udp)in-1080-tcp)The single TCP session ever recorded from the AmneziaWG inbound was routed to
blockedby a user geoip rule, i.e. it was not a successful relay either.Reality proves Xray itself, the routing rules and outbound egress are healthy. Only the AmneziaWG path fails to deliver TCP.
This is not a network / MTU / path problem. A
tcpdumpon the UDP listener port shows healthy bidirectional traffic during a browsing attempt:So the peer is transmitting real payload and the server is answering. The traffic simply never materialises as TCP sessions inside Xray.
How to reproduce the problem
access.logby the AmneziaWG inbound tag:accepted udp:...:53andaccepted udp:...:443(QUIC) entries appear normallyaccepted tcp:entries do not appear at allExpected behavior
TCP sessions originating from AmneziaWG peers reach the dispatcher and are routed like traffic from any other inbound, exactly as the UDP sessions already do.
Actual behavior
Only UDP is relayed. DNS (udp/53) and QUIC (udp/443) work, so the peer looks "online" and counters grow, but every TCP connection silently dies before reaching Xray — so no page loads.
Secondary observation: header protection cannot be cleared via reconcile
While narrowing this down I hit a separate defect. Clearing
headerProtectionKey(and settings3/s4to 0) is rejected forever, because reconcile merges into the live device and merge cannot unset an already-enabled header protection. The warning repeats every 10 s indefinitely and leaves the peer stuck at "connecting" (see logs).The only way out is to disable and re-enable the inbound, so the device is recreated from scratch instead of merged. Reconcile should probably tear down and rebuild the device when a parameter that cannot be merged changes.
Things already ruled out
H1–H4instead of ranges;headerProtectionKey/contentPaddingAddition/I1/randomTrailersremoved;S3=S4=0; keepingJc/Jmin/Jmax/S1/S2). No change: still UDP-only.DOCKER-USERcontains only two unrelated fail2ban ipset rules, and the packet capture confirms packets flow both ways.Relevant logs
Screenshots
No response
3x-ui version
3.7.0
Xray-core version
26.7.28
How did you install 3x-ui?
Docker / Docker Compose
Operating system
Ubuntu, Linux 5.15 x86_64, 1 GB RAM VPS
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 (Aug 25, 2026):
Your secondary observation is a real, confirmed bug and I can point at the exact line — clearing
headerProtectionKeyis impossible on a live interface, and the failed reconcile it causes leaves the device with zero peers, not just an unchanged setting. Your primary claim (TCP never relayed) I could not confirm from the source: I traced the whole TCP path and found no defect that would kill TCP while leaving UDP working, but I also found that every failure branch on that path logs nothing at all, so I need three specific things from you before I can call it. Details for both below.1. Secondary defect — confirmed
buildUAPIConfigemits the AWG 3.x device lines only when they are non-empty:Same gate for
content_padding_addition(device.go:223), the four timers, andwriteOptionalLineforh1-h4/i1-i5(device.go:265-274). On a UAPI set operation an absent line means "leave unchanged" — so clearing the field in the panel emits no line at all and the running device keeps the old key forever.The project already knows this, for the two
boolfields only:random_trailers/disable_cookiesare therefore emitted unconditionally (device.go:241-242). The string fields were not given the same treatment, and there is no test for the on→off direction:TestEnsureHeaderProtectionKeyChangeReconfiguresInPlace(manager_test.go:250) only covers off→on.Why it can never rebuild its way out: the rebuild-vs-reconfigure decision keys on MTU and addresses only —
so an obfuscation-only edit always takes the in-place branch (
manager.go:125), andcur.uapiConfigis only updated after a successfulIpcSet(manager.go:151-156) — a failing config is retried verbatim every 10s forever. That is exactly the repeat you saw.There are two variants, and the quiet one is worse:
headerProtectionKey, leaveS1-S4≥ 12IpcSetsucceeds, header protection stays enabled on the live device, nothing is loggedheaderProtectionKeyand dropS3/S4below 12IpcSetfails withIPC error -22every 10s — your caseThe panel permits the second combination:
ValidateObfuscationonly enforces the ≥12 floor when the key is non-empty (internal/amneziawg/params.go:156-160), whileS3/S4are otherwise allowed down to 0 (params.go:139-143). And the panel always generates a key for a new inbound (params.go:66), so every inbound starts in the state that cannot be undone.The peer wipe.
buildUAPIConfigwritesreplace_peers=trueatdevice.go:201, theheader_protection_keyline atdevice.go:216, and the peer blocks last atdevice.go:244. The panel's own comment states whatreplace_peersdoes:So a config that fails at the header-protection stage has already dropped every peer and never re-adds them. That matches your "peer stuck at connecting", and it is why disable/re-enable (which forces the rebuild branch,
manager.go:162-167) is the only way out. Inference, flagged as such: I could not readamneziawg-go's source from this checkout, so the exact point at which it validates the merged config — and therefore that the peer lines are never reached — is reasoned from the emit order above plus your log, not read from the library. Note also that your error text namesS2while the panel's own guard namesS1-S4(params.go:159); I can't see which value the library actually rejected, and I'm not going to invent a reason for the mismatch.Workaround until this is fixed: never edit obfuscation on a live AmneziaWG inbound expecting a field to be cleared. Disable the inbound, save, re-enable it — that rebuilds the device from scratch and is the only path that applies a cleared value.
2. Primary claim — not confirmed, and here is exactly what I ruled out
What I could establish from the source:
internal/amneziawgnet/relay.go:104-133,socks5Handshakeatrelay.go:139). Yourproxy/socks: client UDP connection from udp:127.0.0.1:56509line means that TCP connect and the auth succeeded.RelayTCP(relay.go:67-87) dials the identical address with the identical credentials, so it cannot be failing for connectivity or auth reasons. Something upstream of it is.injectAmneziawgnetSocksemits a stock socks inbound with nonetworklimit and reuses the AmneziaWG inbound's own tag (internal/web/service/xray.go:748-755) — that is why your entries carryin-40188-udp; the tag name has nothing to do with the protocol.forwarder.go:42,udp.go:34) and nothing else in the package callsSetTransportProtocolHandler.accepted tcp:line.What I could not establish, and why your report reads as "silent": the TCP path has no logging on any failure branch. If gVisor's forwarder cannot complete the handshake, the connection is dropped here with no message:
and the three peer-lookup bail-outs in
manager.go:178-196are three bareconn.Close()calls.RelayTCPhas exactly two log lines it can ever emit —relay.go:73andrelay.go:78. So "noaccepted tcp:and no warning" is consistent with several different failures and distinguishes none of them.One more gap worth recording for the maintainer: the only end-to-end proof of the TCP relay,
TestSocksRelayAgainstRealXray, configures the device withdev.Configure(inst, DeviceOptions{})(relay_e2e_test.go:188) and a hand-written classic obfuscation set (relay_e2e_test.go:90-93) — no header protection, no content padding, no random trailers, noI1. It therefore never exercises the AWG 3.1 parameter setGenerateObfuscation31actually produces for every new inbound. It is also gated behindXRAY_E2E_BINARY, so it does not run in CI.What I need from you
amneziawgnet:, during one browsing attempt. Specifically: does anyamneziawgnet: RelayTCP:line appear? Present → the failure is on the SOCKS5 leg; absent → it died inside the gVisor forwarder and never reached the relay. That single bit splits the search space in half.AMNEZIAWGNET_DEBUG=1in the environment (internal/amneziawgnet/manager.go:27-32— any non-empty value) and paste what appears while a page fails to load. This is opt-in for exactly this kind of question.RandomTrailersto off on the inbound and retest TCP. The panel defaults it to on for every new inbound (internal/amneziawg/params.go:94), it is documented as needing both ends to agree or packets are "silently dropped by the other" (internal/amneziawgnet/device.go:48-59), and it is the one field your ruled-out list does not mention. It was also isolated as the dominant factor in #6303 on this same code path. Do this after a disable/re-enable cycle, otherwise defect 1 above means your edit may not have reached the running device at all.Please paste all of it as text — I cannot open images.
Verdict: Confirmed bug (the reconcile/header-protection defect; the TCP-only claim is unresolved — see "Not determined")
Severity: High
Confidence: High for the confirmed defect; Low for the reported TCP-only symptom
Root cause:
buildUAPIConfiggatesheader_protection_keyon a non-empty value (internal/amneziawgnet/device.go:216), and the same forcontent_padding_addition, the four timers andwriteOptionalLine'sh1-h4/i1-i5(device.go:223-240, 265-274). An absent UAPI line means "unchanged", so a cleared field can never be applied to a running device.addressFingerprint(manager.go:258-260) covers only MTU and addresses, so an obfuscation-only edit always takes the in-place branch (manager.go:125) and never rebuilds;cur.uapiConfigis updated only after a successfulIpcSet(manager.go:151-156), so a rejected config retries verbatim every 10s. Triggering condition: clearheaderProtectionKeyon a live inbound — silently ineffective ifS1-S4stay >= 12, and a permanentIPC error -22loop ifS3/S4are also lowered, whichValidateObfuscationallows once the key is empty (internal/amneziawg/params.go:139-143, 156-160). Becausereplace_peers=true(device.go:201) is emitted before the failing line and before the peer blocks (device.go:244), the failed apply leaves the interface with no peers. Introduced with the feature itself:effccccefeat(amneziawg): add native AmneziaWG protocol support (#6105).Already fixed: Still present on the default branch (
f727d04f, v3.7.0).git log -- internal/amneziawgnet/returns onlyeffcccce; no follow-up commit touchesbuildUAPIConfigoraddressFingerprint.Duplicate of: None. Related: #6303 (AmneziaWG throughput collapse, same package,
RandomTrailersisolated there as the dominant factor) — different symptom, root cause not shown to be shared, so not a duplicate.Evidence:
device.go:216if opts.HeaderProtectionKey != "" {;device.go:241-242fmt.Fprintf(&b, "random_trailers=%t\n", opts.RandomTrailers)emitted unconditionally;device_test.go:385-388"Unlike HeaderProtectionKey/ContentPaddingAddition, these two lines must always be present ... would break the reconfigure-in-place diff for a true->false edit";manager.go:98-101"its own implementation of that op is device.RemoveAllPeers(), unconditionally";manager.go:151-156;manager.go:258-260;params.go:66o.HeaderProtectionKey = generateHeaderProtectionKey();params.go:156-160;manager_test.go:250andmanager_test.go:310cover only off->on and the low-S rejection, never on->off. For the TCP claim:relay.go:104-133+relay.go:139(UDP ASSOCIATE proves TCP connect + auth to the relay inbound already succeed),forwarder.go:31-35andmanager.go:178-196(silent drops),xray.go:748-755(relay inbound has no network restriction),relay_e2e_test.go:188(DeviceOptions{}— the only TCP e2e proof never runs the default AWG 3.1 parameter set, and is gated onXRAY_E2E_BINARY).Not determined: Whether TCP is genuinely never relayed, and where it dies. The single check that splits it: whether a
amneziawgnet: RelayTCP:warning (relay.go:73orrelay.go:78) appears during a failing browsing attempt — absent means the connection died inforwarder.go:31-35before the relay was ever called. Also not verifiable from this checkout:amneziawg-go's own ordering of config validation versus peer lines (it is not vendored here), so the "peers are wiped" consequence is reasoned from the emit order plus your log, not read from the library.Suggested fix: Emit the AWG 3.x string fields unconditionally (empty value = clear) exactly as
random_trailers/disable_cookiesalready are atdevice.go:241-242, or — ifamneziawg-gohas no UAPI spelling for "clear" — add the AWG 3.x fields that cannot be merged toaddressFingerprint(manager.go:258) so clearing one forces the rebuild branch instead of a doomed in-placeIpcSet. Either waymanager.go:151-153should not be able to leave a running interface with zero peers after a rejected apply.@MHSanaei — confirmed High-severity defect above; leaving the issue open for the TCP half.
This reply was generated automatically; a maintainer may follow up.
@bharmalej commented on GitHub (Aug 25, 2026):
Thanks — that analysis was extremely useful, and it turned out my original framing was wrong.
AMNEZIAWGNET_DEBUG=1shows this is not a TCP-specific defect at all. The session itself cannot be maintained; TCP is simply the first thing to die because it needs more than one round trip.I ran two controlled tests on the same build, both with debug enabled. All three of your questions are answered below.
Answer to Q1 — no
RelayTCP:lines, in either runZero across both runs. But the reason is upstream of the forwarder: there is no live session to deliver anything over, so nothing ever reaches
RelayTCP.Answer to Q2 — the device log, and what it shows
This is the actual signature (run B, trimmed):
Exactly one handshake ever completes, and it is always the client-initiated one. Every subsequent handshake — all of them server-initiated rekeys — fails; the client never answers. The session dies ~15-20 s after it is established and can never be re-established from the server side.
That explains the UDP/TCP asymmetry I originally reported, and it is not a TCP bug:
access.logis timestamped within the same second as the successful handshake — 10 of them at17:44:19in run A, 9 at17:49:45in run B, then nothing.accepted tcp:is never logged.Answer to Q3 —
RandomTrailersoff changes nothingTested, with the disable/re-enable cycle you specified so defect 1 could not mask the edit. Both runs on the same build, same client, same browsing steps:
Received handshake initiationSending handshake responseSending handshake initiation(server)Handshake did not completeReceived message with unknown typeRetrying ... stopped hearing backRelayTCP:linesaccepted tcp:accepted udp:Run A was the untouched parameter set the panel generates for a new inbound (
GenerateObfuscation31):headerProtectionKeyset,randomTrailers=true,contentPaddingAddition=14-44,i1=<r 231>,h1-h4as ranges,s1=110 s2=34 s3=23 s4=14, no MTU override.Run B: fixed
h1-h4,randomTrailers/contentPaddingAddition/i1removed,s3=s4=0, and the five AWG 3.1 timers pinned to classic WireGuard values (rekeyAfterTime=120,rejectAfterTime=180,rekeyTimeout=5,keepaliveTimeout=10,maxHandshakeAttempts=18). Client profile re-imported both times.The signature is identical. So the obfuscation parameter set is not the cause — this rules out
RandomTrailers, theh1-h4ranges, header protection, content padding,I1,S3/S4, and the randomized timers, all at once.Two more things worth recording
1. Header protection may be impossible to disable at all, not just impossible to clear on a live device. In run B the stored settings have no
headerProtectionKeyat all (the JSON key is absent, not empty), andcontent padding additionis correctly not emitted — yet the device still logs:on a freshly rebuilt device. Per your reading of
device.go:216that line is only written when the value is non-empty, which would mean the panel supplies a generated key even when storage has none — consistent withparams.go:66. Flagged as inference: I cannot readamneziawg-gofrom here, so I cannot rule out that the library logs that line for a clear operation too.2. The
S2in the error text is misleading — reproduced. Clearing the key withs2=34(well above the 12 floor) and onlys3/s4at 0 still produces:So the message names
S2while the values actually below the floor areS3/S4. Whatever the fix, that string is going to misdirect anyone who hits it.Environment
Unchanged from the original report: 3x-ui v3.7.0, Xray-core 26.7.28, Docker, Linux 5.15 x86_64. Client is iOS.
The inbound is still up on my node with
AMNEZIAWGNET_DEBUG=1enabled, so I can run further experiments on request — just say what to change and what to capture.@github-actions[bot] commented on GitHub (Aug 25, 2026):
Your refined framing holds up against the source, and it does more than that: I can now confirm from the code that run B really did reach the device with the parameters you set, so ruling out the obfuscation set is a sound conclusion and not an artefact of defect 1. What your data also shows is something no code in
internal/amneziawgnetcan cause — the device stops receiving from the peer entirely, including stateless handshake initiations. Below: what is now settled, two corrections to your "worth recording" items, and the one measurement that splits the two remaining mechanisms.1. What your data settles
The TCP-specific defect is off the table. Zero
RelayTCP:lines plus zeroaccepted tcp:is exactly what a dead session produces, and nothing in the package has a TCP-only path — this matches what I could establish last time fromforwarder.go:31-35/xray.go:748-755. Your explanation of the UDP/TCP asymmetry is the one the code supports.Run B's parameters genuinely reached the device. Every step from storage to the UAPI string is a verbatim copy, with nothing filled in:
ServerSettings.Obfuscation()is a pure field-for-field copy of the parsed JSON (internal/amneziawg/types.go:220-236), consumed byInstanceFromInboundatinternal/amneziawg/instance.go:70.Ensurecall sites map those fields straight across — the reconcile job (internal/web/job/amneziawg_job.go:41-52) and both CRUD paths (internal/web/runtime/local.go:65-75and:198-208) are byte-identical in what they set, so no two paths can fight each other.normalizeAmneziaWGSettingsonly trims and canonicalizes on save; it never supplies a missing value:The 10s reconcile is not what kills your session — and your own log proves it.
Retrying handshake because we stopped hearing back after 15 secondsat17:50:00is that peer object's ownnewHandshaketimer, armed when the server sent data at17:49:45. The reconcile job runs@every 10s(internal/web/web.go:295), and any re-apply goes throughreplace_peers=true(internal/amneziawgnet/device.go:201), whose implementation the package documents asdevice.RemoveAllPeers()(manager.go:96-101) — that would destroy the peer and its timers. A timer surviving 15s means at least one full tick passed with the peer intact, i.e. the byte-identical no-op branch (manager.go:137-149) is working as designed. So peers are not being wiped under you.2. Two corrections
The panel is not supplying a header protection key in run B.
params.go:66lives insideGenerateObfuscation31, whose only server-side caller isdefaultAmneziaWGServer(internal/web/service/inbound_amneziawg.go:114-115), andnormalizeAmneziaWGSettingscalls that only when the settings blob is empty /null/{}or has noserverblock at all (inbound_amneziawg.go:171-200). Your inbound has a server block, so that path cannot run;opts.HeaderProtectionKeyis then""anddevice.go:216emits no line. SoUAPI: Updating header protection keyon a freshly rebuilt device is being written by amneziawg-go itself, not prompted by anything the panel sent. I cannot read that library from this checkout (not vendored), so I can neither confirm nor rule out that it logs the line for a clear/no-op — recording it as unresolved rather than guessing.The
S2wording is upstream.S2 must be more then 12 to use headerProtection(including the "more then" typo) appears nowhere in this repository — grep returns nothing. It is amneziawg-go's own message, so that misdirection can only be corrected upstream. The panel's own guard does name the right index (internal/amneziawg/params.go:156-161).3. The part that cannot come from this package
Three facts together:
stopped hearing back after 15 secondsonly fires when nothing authenticated arrives from the peer.ip -6 addrfor per-peer IPv6 aliases (internal/amneziawgnet/v6alias.go:106), and port-forwarding is deliberately userspace listeners rather than DNAT — "this path's replacement for the retired kernel-module architecture's PostUp/PostDown iptables DNAT rules: there's no real OS network interface here for DNAT to rewrite packets on" (portfwd.go:6-8). The UDP socket is amneziawg-go's ownawgconn.NewDefaultBind()(device.go:139), never rebound.So the client's packets are either dropped before they reach the socket, or the device's own receive path stopped. Everything else you have measured is downstream of that one bit.
4. What to capture next
Please run these during one failing browsing attempt, on the same node:
ss -uanp | grep <your UDP port>inside the container, sampled ~3 times a few seconds apart. A climbingRecv-Qmeans packets reach the socket and the device is not draining them (server-side, and squarely a bug).Recv-Qpinned at 0 while the client is transmitting means they never arrive at the socket at all. This is the bit that decides everything else.iptables -L -n -vinside the container, plus the two rules you saw inDOCKER-USERon the host, with their packet counters, taken during the failure. This matters more than it looks: the image's bundled fail2ban jail bans UDP on every port except SSH and the panel port — withmaxretry=1,findtime=32,bantime=30m(DockerEntrypoint.sh:18-20), enabled by default in the shipped compose file (XUI_ENABLE_FAIL2BAN: "true"). A DROP there is invisible totcpdump, which taps before the filter chains — which is exactly the shape of "packets on the wire, nothing in the device". Also please pastecat /var/log/x-ui/3xipl-banned.logand say whether your client's public IP appears there.nstat -az | grep -i Udp(ornetstat -su) before and after the failure, so we can see whetherreceive buffer errors/packet receive errorsmove.Text only, please — I cannot open images.
Verdict: Confirmed bug (the reconcile/header-protection defect, unchanged from my previous comment; the session-death symptom is still unresolved — see "Not determined")
Severity: High
Confidence: High for the confirmed defect and for the rulings-out in §1-§2; Low for the cause of the session death
Root cause: Unchanged for the confirmed defect:
buildUAPIConfiggatesheader_protection_keyon a non-empty value (internal/amneziawgnet/device.go:216), an absent UAPI line means "unchanged", andaddressFingerprint(manager.go:258-260) covers only MTU/addresses so an obfuscation-only edit never rebuilds. Introduced with the feature itself,effcccce. For the session death: no root cause ininternal/amneziawgnet— the package installs no netfilter rule (onlyip -6 addr,v6alias.go:106), does not rebind the device socket (device.go:139), and the reporter's own 15snewHandshaketimer at 17:50:00 rules out areplace_peerspeer wipe by the 10s job (web.go:295,manager.go:96-101,device.go:201).Already fixed: Still present on the default branch (
f727d04f, v3.7.0);git log -- internal/amneziawgnet/still returns onlyeffcccce.Duplicate of: None. Related: #6303 (same package, throughput collapse) — this thread's run B now rules
RandomTrailersout for this symptom, so still not a duplicate.Evidence:
internal/amneziawg/types.go:220-236andinstance.go:70(pure copy, no defaults);internal/web/job/amneziawg_job.go:41-52,internal/web/runtime/local.go:65-75,:198-208(all three call sites identical);internal/web/service/inbound_amneziawg.go:171-200(defaultAmneziaWGServer/GenerateObfuscation31unreachable once a server block exists) and:201-208(trim/canonicalize only);internal/amneziawgnet/device.go:216(if opts.HeaderProtectionKey != "" {);manager.go:96-101("its own implementation of that op is device.RemoveAllPeers(), unconditionally");manager.go:137-149(no-op branch);web.go:295(cadenceAmneziaWG = "@every 10s");portfwd.go:6-8(userspace listeners, explicitly not DNAT);v6alias.go:106(the package's only exec);DockerEntrypoint.sh:55-56(ban action covers UDP on all non-exempt ports) and:18-20(maxretry=1,findtime=32,bantime=30m); repo-wide grep formore then 12returns nothing.Not determined: Why the device stops receiving authenticated packets from the peer roughly a second after the handshake, while the client is still transmitting. The single check that splits it:
Recv-Qon the device's UDP socket during the failure (item 1 above) — climbing means the receive path stalled server-side, zero means the packets are being dropped before the socket. Also still unverifiable here: amneziawg-go's own logging and validation behaviour, since the module is not vendored in this checkout.Suggested fix: Unchanged and scoped to the confirmed defect only: emit the AWG 3.x string fields unconditionally (empty = clear) exactly as
random_trailers/disable_cookiesalready are atdevice.go:241-242, or add the fields that cannot be merged toaddressFingerprint(manager.go:258) so clearing one forces the rebuild branch instead of a doomed in-placeIpcSet.I have retitled the issue to match what you now describe; the old title was "[Bug]: AmneziaWG inbound relays UDP but never TCP — peers connect and resolve DNS, but no TCP session reaches Xray". Keeping "clarification needed" on until item 1 comes back.
@MHSanaei — no change to the confirmed defect above; this update only rules the AWG 3.1 parameter set out as the cause of the reporter's connection failure.
This reply was generated automatically; a maintainer may follow up.
@bharmalej commented on GitHub (Aug 25, 2026):
All four items from your list, captured on the same node/build.
1.
Recv-Qduring a live failure — pinned at 0, and it tells us more than "not stalled"Sampled
netstat -uanp+/proc/net/snmpevery 3s across two separate live sessions (iPhone, then macOS AmneziaWG client). Full window, not cherry-picked:Recv-Qnever left 0 across ~35 samples spanning both sessions.InErrorsandRcvbufErrorsnever moved from 0, in either session. ButInDatagramsjumps in clean steps every time a burst of packets lands — so packets are reaching the socket and being drained instantly, with zero backlog and zero kernel-level drops.That's a third outcome, not quite either of the two you offered: not "stalled with a growing backlog," not "never arrives at the socket." Everything that arrives is read cleanly and immediately. Whatever is killing the session is entirely inside
amneziawg-go's own state machine, above the socket.2. iptables / fail2ban — checked from inside, ruled out two ways
You were right to flag this — the image does ship
XUI_ENABLE_FAIL2BAN=trueby default and I hadn't set that variable myself, so it's on:But:
Zero across both test sessions (iPhone then Mac, different local devices).
/var/log/x-ui/3xipl-banned.logis empty — 0 bytes.And structurally it cannot ban here even if it wanted to:
No
CAP_NET_ADMIN, soiptablescan't even read the ruleset, let alone-Ia ban rule. On the host,DOCKER-USERonly carries two ipset rules from an unrelated haproxy-fail2ban setup (49 and 0 entries respectively) — neither references the AmneziaWG port. So fail2ban is running but inert for this path.3. nstat / netstat errors — same data as item 1, both sessions clean
Covered above:
InErrors=0,RcvbufErrors=0for the full duration of both the iPhone session and the Mac session. No error counter moved at any sample point.4. Second client, different device — done, with a caveat worth flagging myself
Installed AmneziaWG on macOS on a separate physical machine and reproduced. Caveat: same public IP as the iPhone — both devices are behind the same home NAT, so this does not control for per-source-IP filtering the way you intended. I don't have a second vantage point on a different network to test from right now.
For what it's worth, the failure signature is byte-for-byte identical to the iPhone run:
Same ~15s session lifetime, same endless failed rekey loop, zero
accepted tcp:for the whole session. Different OS, different WireGuard/AmneziaWG client implementation, same result. Whatever this is, it isn't specific to Apple's mobile WireGuard stack.One more data point I wasn't asked for: the first TCP session of the entire investigation
During the iPhone run, exactly one TCP session finally appeared:
Same Apple IP, QUIC and TCP fired within the same millisecond — that pattern looks like an OS-level connectivity probe racing both protocols to one endpoint, not a Safari page load, so I'm not claiming "TCP works now." But the timing is exactly consistent with everything else here: it landed in the same ~300 ms burst as the handshake completion logged one second earlier (
18:13:20handshake response, first UDP/TCP traffic at18:13:21.1-18:13:21.5), i.e. it snuck through inside the brief live window before the session died again. This is more evidence for, not against, the "session lives ~15-20s then can't be re-established" mechanism — TCP isn't structurally blocked, it just essentially never gets a wide enough window.Summary
Nothing in this round points at anything outside
internal/amneziawgnet's own session/handshake handling: the kernel path is clean (item 1/3), the only firewall in the picture is provably inert (item 2), and the failure reproduces identically on a second OS/client on the same node (item 4). I don't have the means to test from a genuinely different public IP right now — if that's still a live hypothesis for you, let me know what would distinguish it and I'll see what I can arrange.@github-actions[bot] commented on GitHub (Aug 25, 2026):
Your data pushed me to look at the one place I had not: the goroutine the decapsulated packets are delivered on. There is a real defect there —
AttachUDPHandlerruns the SOCKS5 relay synchronously on the tunnel's own per-peer packet-receive goroutine, with no read deadline, whileAttachTCPForwarderdeliberately does not. Anything that stalls that relay stalls every subsequent packet from that peer, TCP and UDP alike, and stops amneziawg-go from ever registering "I heard from this peer". That is exactly the shape of your failure. I also have one correction to item 1:Udp: InDatagramsdoes not show what you concluded.1. The defect
AttachTCPForwarderruns its handler on a fresh goroutine, on purpose:and
RelayTCP's own doc says why: "Blocks until the relay ends; meant to be called from (or as) an AttachTCPForwarder handler, which already runs each connection on its own goroutine" (relay.go:64-66).AttachUDPHandlerhas no such goroutine:Which goroutine is that? The package states it itself, in
newUnconfiguredDevice's doc comment:So the chain for every client→server packet is: amneziawg-go's per-peer receive routine →
stackTun.Write→t.ep.InjectInbound(netstack.go:180-197) → gVisorDeliverNetworkPacket/DeliverTransportPacket→ the callback above, inline. The package's own comment records the assumption that this returns fast:That holds for TCP. It does not hold for UDP, because the handler
Managerattaches (manager.go:199-209) callsm.Lookup(which takes the Manager mutex,manager.go:336-343) and thenudpRelay.Handle, andHandleopens the SOCKS5 association before it spawns any goroutine:newSocks5UDPSessionis a TCP connect plus two full request/response exchanges (relay.go:104-133): greeting + username/password (socks5Handshake,relay.go:139-173), then UDP ASSOCIATE + reply (relay.go:117-125). Only the dial is bounded:Every read after it is a bare
io.ReadFullonctrlwith no deadline (relay.go:144,relay.go:163,relay.go:179,relay.go:193);grep -n SetDeadline internal/amneziawgnet/relay.goreturns only the pump's 2-minute one atrelay.go:369. A SOCKS5 peer that accepts the TCP connection and then does not answer parks that goroutine forever.And it happens per source port, not per client. Sessions are keyed by
u.sessions[src.String()](relay.go:337) — IP and port. A resolver that uses a fresh ephemeral port per query, or a browser opening QUIC connections, opens a brand-new TCP control connection + 3 round trips for each one, all serialized on the tunnel's receive path. Your 10accepted udp:entries inside one second are 10 sequential associations, with every other packet from that peer — including TCP SYNs — queued behind them.2. What this explains, and what it does not
Explains, without needing anything outside the panel:
RelayTCP:lines and zeroaccepted tcp:. Delivery is strictly serialized on one goroutine; a TCP SYN behind a stalled UDP association is never delivered tofwd.HandlePacketat all, so the forwarder is never entered and nothing can log.Recv-Qpinned at 0. The socket reader is a different goroutine from the per-peer delivery routine, and your sessions are far too short to fill the per-peer queue between them. Backlog on the socket is exactly what you would not expect here.tun.Write; stall it and the timer fires on schedule. Flagged as inference: amneziawg-go is not vendored in this checkout (go.mod:6,github.com/amnezia-vpn/amneziawg-go/v3 v3.1.20260814, not in the module cache here), so I am reasoning about its routine layout, not reading it.18:13:21.496833landing in the same burst as the handshake: before anything stalled.Does not explain, and I am not going to pretend otherwise: why your server-initiated rekeys get no answer. Handshake messages are processed on a device-wide routine, not the per-peer one, so a stalled delivery path should still let a client's handshake response through. Either something else is also dropping packets on the path, or my reading of the routine split is wrong. Item 1 below settles which.
3. Correction to item 1
Udp: InDatagramsin/proc/net/snmpis a network-namespace-wide counter, not a per-socket one. Inside this container it also counts the loopback SOCKS5 UDP relay traffic between the panel and Xray (127.0.0.1:65104for inbound 4 —SOCKSBasePort = 65100+ inbound id,socks_config.go:12-18) and Xray's own DNS. Your own log lineproxy/socks: client UDP connection from udp:127.0.0.1:56509is one of the things incrementing it. So "InDatagrams jumps in clean steps" is consistent with your client's packets arriving — and equally consistent with them not arriving while the panel↔Xray loopback path keeps ticking. It does not distinguish the two.Recv-Qat 0 andInErrors/RcvbufErrorsat 0 remain valid and useful; that one inference does not.4. Two things that would close this
You have pprof available in this build — it is off by default and env-gated:
XUI_PPROF=trueto the container environment, restart, reproduce, and while the session is silent run inside the container: Paste every stack containingamneziawgnet. This is decisive. A goroutine parked inamneziawgnet.(*UDPRelay).Handle/socks5Handshake/readSocks5ReplywithstackTun.WriteorDeliverTransportPacketbelow it proves the defect above is your cause. None parked there means the delivery path is idle — i.e. nothing is arriving for it to deliver — and the answer is on the network path, not in this package. While you are there,netstat -tan | grep -c 65104tells us how many SOCKS5 control connections have piled up.nsenter -t $(docker inspect -f '{{.State.Pid}}' 3x-ui) -n tcpdump -ni any -tttt udp port 40188. Your earlier capture was upstream of Docker's DNAT; this one is the only place that shows what actually reached the panel's socket, which is the question item 1 turned out not to answer.The header-protection defect from my first comment is unchanged and unaffected by any of this.
Verdict: Confirmed bug
Severity: High
Confidence: High that the defect below exists and is reachable on every AmneziaWG inbound; Medium that it is the cause of this reporter's session death (see "Not determined")
Root cause:
AttachUDPHandlerinvokes its handler inline inside gVisor's transport-protocol callback (internal/amneziawgnet/udp.go:34-40,handler(src, dst, data)at :38), which the package itself documents as running on "the peer's receive goroutine" (device.go:113-116), reached viastackTun.Write->ep.InjectInbound(netstack.go:180-197). The handlerManagerattaches there (manager.go:199-209) callsUDPRelay.Handle, which performs a full SOCKS5 UDP ASSOCIATE — TCP connect plus greeting/auth plus associate — before spawning any goroutine (relay.go:340-351,go u.pumponly at :350). Only the dial is bounded (relay.go:105, 5s); every subsequentio.ReadFullon the control connection has no deadline (relay.go:144,:163,:179,:193), so a SOCKS5 peer that accepts and does not answer parks the tunnel's delivery path indefinitely. Amplified byu.sessionsbeing keyed onsrc.String()(relay.go:337) — IP and port — so every new client source port pays a fresh connect + 3 round trips on that same path. Triggering condition: any UDP flow from a peer whose association is slow or hung; everything behind it, TCP included, is never delivered. Introduced with the feature itself:effccccefeat(amneziawg): add native AmneziaWG protocol support (#6105).Already fixed: Still present on the default branch (
f727d04f, v3.7.0).git log --oneline -- internal/amneziawgnet/returns onlyeffcccce.Duplicate of: None. Related: #6303 (AmneziaWG throughput collapse) — a per-source-port blocking associate on the receive path is a plausible contributor there too, but I have not shown it, so not a duplicate.
Evidence:
udp.go:38handler(src, dst, data)with no goroutine, againstforwarder.go:27go func(r *tcp.ForwarderRequest) {;relay.go:64-66"Blocks until the relay ends; meant to be called from (or as) an AttachTCPForwarder handler, which already runs each connection on its own goroutine";device.go:114-115"DATA RACE between stack.(*nic).DeliverTransportPacket (the peer's receive goroutine, reading the handler table)";netstack.go:78-82"upload/client->server direction has no equivalent stall ... returns immediately" — the assumption this breaks;netstack.go:180-197(Write->InjectInbound);relay.go:342newSocks5UDPSession(...)ahead ofrelay.go:350go u.pump(src, sess);relay.go:105sole timeout;relay.go:144/163/179/193deadline-lessio.ReadFull;relay.go:337session keysrc.String();manager.go:199-209+manager.go:336-343(the handler also takes the Manager mutex). Secondary hazard, flagged as inference since amneziawg-go is not readable here:ensureLockedholdsm.muacrosscur.dev.IpcSet(manager.go:151) andcur.dev.Close()(manager.go:165); if either waits for a peer's receive routine to drain while that routine is parked inm.Lookup, that is a lock inversion that would freeze the whole Manager. No test covers a slow or unresponsive SOCKS5 server —relay_e2e_test.gohas onlyTestSocksRelayAgainstRealXrayandTestManagerEnsureAutomaticallyWiresRelay, both gated behindXRAY_E2E_BINARYand neither running in CI.Not determined: Whether this defect is what stalled your device, and separately why your server-initiated rekeys go unanswered when handshake processing should not sit on the stalled routine. The single check that settles the first: the goroutine dump in item 1 — a stack parked in
UDPRelay.Handle/socks5HandshakeunderstackTun.Writeconfirms it, its absence rules it out. Still unreadable from this checkout: amneziawg-go itself (go.mod:6, not vendored and not in the module cache), so every claim about its internal routine layout above is inference, not source.Suggested fix: Take the SOCKS5 association off gVisor's delivery callback the way
AttachTCPForwarderalready does atforwarder.go:27— either spawn the handler, or at minimum haveUDPRelay.Handlecreate the session on its own goroutine and queue the first datagram. Independently,newSocks5UDPSessionshould set a deadline onctrlaround the greeting/auth/associate exchange rather than relying on the dial timeout alone.@MHSanaei — confirmed High-severity defect on the embedded AmneziaWG receive path; the header-protection defect from earlier in this thread stands as well. Leaving the issue open pending the goroutine dump.
This reply was generated automatically; a maintainer may follow up.
@bharmalej commented on GitHub (Aug 25, 2026):
Ran both. Your own stated criterion for item 1 resolves this cleanly, and item 2 independently agrees.
Item 1 — goroutine dump: zero matches for the predicted stack
Two snapshots via
XUI_PPROF=true, both timestamped solidly inside a dead window (handshake response logged at18:45:58, session went silent at18:46:14; snapshots taken at18:46:34and18:46:56):There are
pumpgoroutines parked in(*socks5UDPSession).receive,[IO wait]— but that's the expected steady state;pumpalready runs on its own goroutine per your own read ofrelay.go:350. Neither snapshot has a goroutine parked inline inside the delivery callback with a SOCKS5 handshake underneath it. 60 total goroutines in the second snapshot, none matching.Per your own stated test: "A goroutine parked in
UDPRelay.Handle/socks5Handshake/readSocks5ReplyunderstackTun.WriteorDeliverTransportPacketconfirms it. Its absence rules it out." It's absent, in both snapshots.Item 2 — capture inside the container's network namespace: also zero
Couldn't get root for
nsenteron this host, so I joined the same netns a different way —docker run --rm --net=container:3x-ui --cap-add=NET_ADMIN --cap-add=NET_RAW alpine tcpdump— same effect, past Docker's DNAT, at the actual delivery point.20 seconds, entirely inside the same dead window (
18:47:11–18:47:26):Server dutifully retries its own rekey every ~5s. Nothing arrives from the client, at the actual socket, for the entire window.
What this settles, and what it leaves open
Both checks agree independently: there is nothing for the delivery path to be stuck on, because nothing is arriving. That's a clean negative for the synchronous-SOCKS5-relay theory as the cause of this session death specifically — the defect you found in
AttachUDPHandleris real (I'm not disputing the code reading), but it can't be what's blocking this particular failure if the goroutine dump shows no delivery-path goroutine ever gets far enough to hang on it.That pushes this back to where your comment #2 already flagged it: something stops the client from transmitting anything — not even a bare handshake retry — for the ~15-20s the session is dead, then it resumes. I don't have visibility into the client's own internal state (iOS/macOS AmneziaWG app), and that's genuinely outside what server-side logs or goroutine dumps can show. If there's a client-side log or debug flag worth checking, I'm open to it, but I think this may be past what this issue's server-side evidence can settle further.
The header-protection defect stands unaffected by any of this.
@github-actions[bot] commented on GitHub (Aug 25, 2026):
Your dump meets the criterion I set, so I withdraw the
AttachUDPHandlerstall as the cause of your session death — it stays a real defect on its own, but it is not what is killing this session. What that leaves is one panel-controlled thing I had not checked, and it is missing: the panel can never emitPersistentKeepalivefor an AmneziaWG client, because nothing anywhere setskeepAlive— there is no UI field for it, and the API is documented as never generating one. A peer with no keepalive is only reachable from the server while the mapping its own last packet opened is still alive, which is exactly the shape of "every server-initiated rekey fails".1. Accepting the ruling-out
No goroutine parked under
DeliverTransportPacket/InjectInboundin either snapshot is the negative I asked for, and your netns capture agrees independently. I am not going to re-argue it. The defect atinternal/amneziawgnet/udp.go:38(handler(src, dst, data)inline, againstforwarder.go:27go func(r *tcp.ForwarderRequest) {) and the header-protection defect from my first comment both stand as confirmed and are actionable now — nothing below is a precondition for either.2. What the panel hands your client
All three independent emitters gate the line on a non-zero value:
and the same at
frontend/src/lib/xray/inbound-link.ts:1024-1025. The value defaults to zero and is never filled in:KeepAlive int \json:"keepAlive" gorm:"column:wg_keep_alive;default:0"`—internal/database/model/model.go:930`preSharedKeyandkeepAlive(WireGuard)" —frontend/src/pages/api-docs/endpoints.ts:871keepAliveform control in the whole frontend is the outbound WireGuard peer editor (frontend/src/pages/xray/outbounds/protocols/wireguard.tsx:155-156); the client editor setswgPreSharedKeyand the allowed-IPs fields only (ClientFormModal.tsx:377-379,:698). The field exists in the inbound schema (frontend/src/schemas/protocols/inbound/amneziawg.ts:26) with nothing bound to it.So every
.conf, QR andvpn://link the panel produces for an AmneziaWG client is a peer with no keepalive. Note the panel does use 25 where it is the WireGuard client rather than the server (frontend/src/pages/xray/overrides/PiaModal.tsx:114,keepAlive: 25), and the AmneziaWG documentation page shows the line in its example client config:That example cannot currently be produced by the panel.
Flagged as inference, and it is the weak point: your silence starts ~1 s after the handshake, far sooner than any ordinary UDP NAT/conntrack idle timeout (Linux
nf_conntrack_udp_timeoutdefaults to 30 s). So a missing keepalive fits "server-initiated rekeys are never answered while the client is idle" well and fits "the return path dies one second in" badly. I can read the emitters, not your path — which is why the next item is one edit and not another capture.3. The cheap test — client side only, no root, no panel change
Open the imported profile on the iOS/macOS client, add one line to the
[Peer]block, save, reconnect:To make it survive a re-download rather than a hand edit, the client's
keepAlivehas to go in through the API —POST /panel/api/clients/update/:emailaccepts it (endpoints.ts:877), but that endpoint "replaces the row, it does not patch" (endpoints.ts:893), so send the full client payload.4. The one gap in what you captured, for completeness
Your netns capture was taken at
18:47:11–18:47:26, inside a dead window — i.e. after the client had already given up. Zero inbound there is what both remaining hypotheses predict, so it distinguishes nothing. The capture that would split them is the same command run during an active browsing attempt — the moment your very first host-side capture showed 7 × 1264-byte data packets going client → server:stopped hearing back after 15 seconds⇒ they arrive and fail to authenticate, which is inside amneziawg-go;Optional — I am not holding the issue open for it.
Verdict: Confirmed bug
Severity: High
Confidence: High for the two confirmed defects and for the
keepAlivegap in §2 (all read as file:line); Low for the cause of your session deathRoot cause: Two confirmed, unchanged from earlier in this thread. (a)
buildUAPIConfiggatesheader_protection_keyon a non-empty value (internal/amneziawgnet/device.go:216); an absent UAPI line means "unchanged", andaddressFingerprint(manager.go:258-260) keys only on MTU/addresses, so an obfuscation-only edit never rebuilds and a cleared field can never be applied. (b)AttachUDPHandlerruns the SOCKS5 associate inline on gVisor's transport callback (udp.go:34-40) with no deadline on the control reads (relay.go:144/163/179/193), unlikeAttachTCPForwarder(forwarder.go:27). Both introduced with the feature itself,effcccce. New this round, and not a cause of the session death but a real gap: no code path ever setsmodel.Client.KeepAlive(model.go:930, default 0) and no UI control binds it, soPersistentKeepaliveis never emitted (internal/sub/service.go:782-783,frontend/src/pages/clients/amneziawgConfig.ts:107-108,frontend/src/lib/xray/inbound-link.ts:1024-1025). For the reporter's session death: no root cause established in this repository — the reporter's goroutine dump rules out (b) as its cause by the criterion I stated, and the delivery path cannot stall on packets that never arrive.Already fixed: Still present on the default branch (
f727d04f, v3.7.0).git log --oneline -- internal/amneziawgnet/ internal/amneziawg/still returns onlyeffcccce.Duplicate of: None. Related: #6303 (same package, throughput collapse).
Evidence:
internal/sub/service.go:782-783if client.KeepAlive > 0 {;frontend/src/pages/clients/amneziawgConfig.ts:107-108;frontend/src/lib/xray/inbound-link.ts:1024-1025;internal/database/model/model.go:930gorm:"column:wg_keep_alive;default:0";frontend/src/pages/api-docs/endpoints.ts:871"Accepted on the same body but never generated:preSharedKeyandkeepAlive(WireGuard)";frontend/src/pages/xray/outbounds/protocols/wireguard.tsx:155-156(the onlykeepAlivecontrol in the frontend, and it is on outbounds);frontend/src/pages/clients/ClientFormModal.tsx:377-379,:698(client editor covers preSharedKey/allowedIPs only);frontend/src/schemas/protocols/inbound/amneziawg.ts:26(field present, unbound);frontend/src/pages/xray/overrides/PiaModal.tsx:114keepAlive: 25;docs/content/docs/en/config/amneziawg.mdx:164PersistentKeepalive = 25in the documented example. Carried forward:internal/amneziawgnet/device.go:216,manager.go:258-260,udp.go:38vsforwarder.go:27,relay.go:64-66,relay.go:105(sole timeout),relay.go:337(session keyed on IP+port).Not determined: Why the peer stops being heard ~1 s after the handshake. The two checks that would split it are in §3 and §4 above; the ~1 s onset is the part a missing keepalive does not explain, and I have flagged that rather than reasoned around it. Still unreadable from this checkout: amneziawg-go itself (
go.mod:6, not vendored), so nothing about its internal receive, decrypt or logging behaviour is source-confirmed here.Suggested fix: Scoped to the confirmed defects only, and unchanged: emit the AWG 3.x string fields unconditionally (empty = clear) as
random_trailers/disable_cookiesalready are atdevice.go:241-242, or add the unmergeable fields toaddressFingerprintso clearing one forces the rebuild branch; and take the SOCKS5 associate off gVisor's delivery callback the wayforwarder.go:27already does. ThekeepAlivegap is separate and smaller — a bound input on the client editor plus a sensible default for AmneziaWG peers.@MHSanaei — no change to the two confirmed defects; new this round is that
PersistentKeepalivecan never appear in a panel-generated AmneziaWG client config, which the documentation example atdocs/content/docs/en/config/amneziawg.mdx:164already shows.This reply was generated automatically; a maintainer may follow up.
@bharmalej commented on GitHub (Aug 25, 2026):
Ran the §3 test. Clean negative, same as you predicted for that outcome.
Hand-edited the same client's
.conf(same server keys, same obfuscation params, only addition:PersistentKeepalive = 25), reimported, reconnected on WiFi:One keepalive arrived right after the handshake, exactly as
PersistentKeepalive = 25should produce. Session still died at the same ~15s mark as every prior run, withaccepted tcp:still at zero. That's expected given your own math on this: the death happens before the next scheduled keepalive (at the 25s mark) would even fire, so this test couldn't have looked any different even if a longer-interval NAT/conntrack expiry were the real mechanism — the configured interval never gets a chance to matter before the first death.So per your own framing: nothing changed, and I agree the server-side evidence is close to exhausted. I don't have a next experiment to propose from this side. Client identity is confirmed unchanged for this run — same AmneziaWG app that's been used throughout this thread, hand-edited config, not a different implementation.
I'll leave the node in its current diagnostic state (
XUI_PPROF=true,AMNEZIAWGNET_DEBUG=1, the two test inbounds) for now in case there's a next round, but I'm pausing active testing here. The header-protection defect and theAttachUDPHandlerinline-relay defect both remain confirmed and actionable independent of whatever is causing this specific session's death.@github-actions[bot] commented on GitHub (Aug 25, 2026):
Your conclusion is probably right, but the test I asked for could not have shown it —
PersistentKeepalive = 25was the wrong number for this symptom's timescale, and the log line you read as proof it was applied does not prove that either. You spotted the first half yourself; the second half is mine to correct. I agree the server-side evidence is exhausted, so I am settling this issue on what is established and dropping the clarification hold.1. Why §3 was under-powered — two reasons, not one
(a) 25 s is above the server's own death threshold. The panel's generator caps the server's
KeepaliveTimeoutdeliberately, and its comment names your exact number:randIntis inclusive on both ends (params.go:27-36), so a sampledKeepaliveTimeoutlands in [8, 20] andRekeyTimeout(params.go:83-84,rtLo := randInt(3, 6), high= rtLo + randInt(1, 4)) in [3, 10]. Your run pinned them to the classic pair, and 10 + 5 = 15 — exactly the interval your log prints. Flagged as inference: that thenewHandshaketimer equalsKeepaliveTimeout + RekeyTimeoutis wireguard-go's own constant, not readable here (go.mod:6, not vendored); your pinned values matching the printed 15 s is the corroboration I have, not a source read.So the server gives up at 15 s and the client's next scheduled keepalive is at 25 s — 10 s late, every time. Your reasoning is correct and I should have specified a value below the threshold in the first place.
Note the direction of the design here, because it cuts against the hypothesis anyway:
params.go:86-87puts the mapping-refresh duty on the server (keep its timeout under the client's 25 s), not on the client. That is the opposite of what my §2 assumed.(b) The keepalive you saw is not evidence the edit took effect.
Receiving keepalive packetimmediately afterSending handshake responseis the session-confirmation packet the initiator is required to send on receiving a handshake response — WireGuard emits it withPersistentKeepaliveunset. Flagged as inference for the same reason as above: amneziawg-go is not in this checkout, so this is protocol behaviour I cannot cite to a line. It means run §3 has no positive control at all — nothing in that log distinguishes "the setting was applied" from "the setting was ignored".If you ever resume, the discriminating value is one comfortably under the server's threshold —
PersistentKeepalive = 5. But I would expect that to come back negative too, and for the reason I flagged last time rather than the one the test gave: your silence starts ~1 s after the handshake, and no keepalive interval addresses a return path that dies inside the first second. So I think your overall read ("obfuscation, NAT and the relay path are all out") stands — just not on the strength of this particular run.2. The one measurement still unrun
For the record, not as a request: your netns capture was taken at
18:47:11–18:47:26, a dead window after the client had given up, so zero inbound there is what both remaining hypotheses predict. The variant that splits them is the same command during an active browsing attempt — the moment your very first host capture showed 7 × 1264-byte data packets going client → server:Those full-size packets present inside the netns while the device still logs
stopped hearing back⇒ they arrive and fail to authenticate, which is inside amneziawg-go and belongs upstream. Absent ⇒ they are lost on the host → container path, outside the panel. Small packets (handshake init, keepalive) getting through while 1264-byte ones do not is the asymmetry that check would resolve.3. What this issue leaves behind — all of it actionable now
Both defects confirmed earlier in this thread stand at the tip (
f727d04f, v3.7.0);git log --oneline -- internal/amneziawgnet/ internal/amneziawg/still returns onlyeffcccce, andgh release listshows nothing newer than v3.7.0.if opts.HeaderProtectionKey != "" {(internal/amneziawgnet/device.go:216) — an absent UAPI line means "unchanged", andaddressFingerprint(manager.go:258-260) keys only on MTU/addresses so an obfuscation-only edit never rebuilds. Silent whenS1-S4stay ≥ 12; a permanentIPC error -22loop, with the peers already dropped byreplace_peers=true, whenS3/S4are also lowered.AttachUDPHandlerruns the SOCKS5 associate inline on gVisor's delivery callback.handler(src, dst, data)with no goroutine (udp.go:38) againstgo func(r *tcp.ForwarderRequest) {(forwarder.go:27), and no deadline on the control reads (relay.go:144/163/179/193). Your goroutine dump ruled it out as the cause of your session death; it remains reachable on every AmneziaWG inbound.PersistentKeepalivecan never appear in a panel-generated client config —internal/sub/service.go:782-783gates onclient.KeepAlive > 0,model.go:930defaults it to 0, and no UI control binds it. §1(a) gives this more weight than I gave it last time: the generator atparams.go:86-87is written on the assumption that clients carry a 25 s keepalive, and the panel is the thing that cannot produce one.Thank you for the diagnostics — the goroutine dump, the netns capture and the two-client control were what let me retract a wrong theory instead of leaving it standing. Leaving this open on the confirmed defects; no further input is needed from you.
Verdict: Confirmed bug
Severity: High
Confidence: High for the three defects/gaps in §3 and for the §1(a) arithmetic (all file:line); Low for the cause of the session death, which is unchanged
Root cause: Unchanged, two confirmed. (a)
buildUAPIConfiggatesheader_protection_keyon a non-empty value (internal/amneziawgnet/device.go:216); an absent UAPI line means "unchanged" andaddressFingerprint(manager.go:258-260) keys only on MTU/addresses, so a cleared field can never reach a running device. (b)AttachUDPHandlerinvokes its handler inline on gVisor's transport callback (udp.go:34-40,handler(...)at :38), unlikeAttachTCPForwarder(forwarder.go:27), with only the dial bounded (relay.go:105) and no deadline on the SOCKS5 control reads. Both introduced with the feature itself,effcccce. Gap, not a cause: no code path setsmodel.Client.KeepAlive(model.go:930, default 0) and no UI control binds it, soPersistentKeepaliveis never emitted. For the reporter's session death: still no root cause established in this repository — the goroutine dump ruled out (b) by the criterion I set, and the delivery path cannot stall on packets that never arrive.Already fixed: Still present on the default branch (
f727d04f, v3.7.0).git log --oneline -- internal/amneziawgnet/ internal/amneziawg/returns onlyeffcccce; latest release is v3.7.0.Duplicate of: None. Related: #6303 (same package, throughput collapse); #6306, #6310 also AmneziaWG but different subsystems.
Evidence:
internal/amneziawg/params.go:86-89"Max 20s: under clients' typical 25s PersistentKeepalive and ~30s NAT UDP timeouts";params.go:27-36(randIntinclusive on both bounds);params.go:83-84(RekeyTimeoutrange [3,10]);internal/sub/service.go:782-783if client.KeepAlive > 0 {;internal/database/model/model.go:930gorm:"column:wg_keep_alive;default:0";frontend/src/schemas/protocols/inbound/amneziawg.ts:26(field present, unbound). Carried forward and re-verified at tip:internal/amneziawgnet/device.go:216if opts.HeaderProtectionKey != "" {;manager.go:258-260;udp.go:38handler(src, dst, data)vsforwarder.go:27go func(r *tcp.ForwarderRequest) {;relay.go:105(sole timeout).Not determined: Why the peer stops being heard ~1 s after the handshake. The single check that would split it is §2 above — a netns capture during an active attempt, not a dead window. The §3 keepalive test did not settle it either way: 25 s exceeds the server's own 15 s threshold, and the post-handshake keepalive is not a positive control. Still unreadable from this checkout: amneziawg-go itself (
go.mod:6, not vendored), so its timer identities, receive path and logging are inference throughout this thread, never source.Suggested fix: Unchanged and scoped to the confirmed defects: emit the AWG 3.x string fields unconditionally (empty = clear) as
random_trailers/disable_cookiesalready are atdevice.go:241-242, or add the unmergeable fields toaddressFingerprintso clearing one forces the rebuild branch; and take the SOCKS5 associate off gVisor's delivery callback the wayforwarder.go:27already does. ThekeepAlivegap is separate and smaller — a bound input on the client editor plus a sensible default for AmneziaWG peers.@MHSanaei — no change to the two confirmed defects; this round only retracts the keepalive theory as a diagnostic and records that the panel cannot emit
PersistentKeepaliveat all, whichinternal/amneziawg/params.go:86-87assumes clients have. Removing "clarification needed" — nothing further is blocked on the reporter.This reply was generated automatically; a maintainer may follow up.