[GH-ISSUE #3304] Android: auto-reconnect when the AmneziaWG tunnel stalls after idle (connection watchdog) #3166

Open
opened 2026-10-25 04:14:49 +07:00 by bsakaguchi · 6 comments
Owner

Originally created by @Dragonsdeath on GitHub (Oct 19, 2026).
Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/3304

AmneziaVPN 5.0.3.1 (AWG 3.1), Android 16, OnePlus 15.
Self-hosted AmneziaWG, mobile network (Russia), battery set
to "Unrestricted" for AmneziaVPN.

Problem
After the phone has been idle with the screen off, the tunnel
sometimes stalls: nothing works (Telegram, browser) until I
manually disconnect and reconnect in AmneziaVPN. It happens
several times a day. A manual reconnect always fixes it
immediately.

What we see on the server side
We captured traffic on our server during these episodes. While
the tunnel is stalled, no packets from the phone reach the server
at all — no handshake initiation, nothing, for 4–44 minutes.
Other devices on the same server work normally at the same time.
Typical sequence: the phone wakes up, sends a few data packets
with the old session from a new NAT port (the mobile operator
changed it during sleep), the server drops them (keys older than
180 s), and then the phone never sends a new handshake. A manual
reconnect opens a new socket, the handshake completes in ~0.1 s,
and traffic flows right away.

Feature request: connection watchdog
An option to detect a stalled tunnel and restart it automatically,
for example:

  • if the latest handshake is older than ~140 s
    (REKEY_AFTER_TIME + KEEPALIVE_TIMEOUT + REKEY_TIMEOUT, as in
    wireguard-tools reresolve-dns) while the app has traffic to send,
    or
  • if a periodic check through the tunnel (ping/HTTP) fails
    N times in a row,
    then recreate the socket and re-handshake — the same as a manual
    reconnect. Configurable interval and on/off switch.

Similar features exist in other clients: WG Tunnel ("Restart
tunnel on ping failure"), mihomo-based clients (fallback groups
with health checks).

Server-side keepalive does not help here: we tried
PersistentKeepalive 25 on the server for this peer — the server
cannot reach the phone after the operator's NAT mapping changes,
only the phone can recover by sending first.

Thank you for AmneziaVPN!

Originally created by @Dragonsdeath on GitHub (Oct 19, 2026). Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/3304 AmneziaVPN 5.0.3.1 (AWG 3.1), Android 16, OnePlus 15. Self-hosted AmneziaWG, mobile network (Russia), battery set to "Unrestricted" for AmneziaVPN. Problem After the phone has been idle with the screen off, the tunnel sometimes stalls: nothing works (Telegram, browser) until I manually disconnect and reconnect in AmneziaVPN. It happens several times a day. A manual reconnect always fixes it immediately. What we see on the server side We captured traffic on our server during these episodes. While the tunnel is stalled, no packets from the phone reach the server at all — no handshake initiation, nothing, for 4–44 minutes. Other devices on the same server work normally at the same time. Typical sequence: the phone wakes up, sends a few data packets with the old session from a new NAT port (the mobile operator changed it during sleep), the server drops them (keys older than 180 s), and then the phone never sends a new handshake. A manual reconnect opens a new socket, the handshake completes in ~0.1 s, and traffic flows right away. Feature request: connection watchdog An option to detect a stalled tunnel and restart it automatically, for example: - if the latest handshake is older than ~140 s (REKEY_AFTER_TIME + KEEPALIVE_TIMEOUT + REKEY_TIMEOUT, as in wireguard-tools reresolve-dns) while the app has traffic to send, or - if a periodic check through the tunnel (ping/HTTP) fails N times in a row, then recreate the socket and re-handshake — the same as a manual reconnect. Configurable interval and on/off switch. Similar features exist in other clients: WG Tunnel ("Restart tunnel on ping failure"), mihomo-based clients (fallback groups with health checks). Server-side keepalive does not help here: we tried PersistentKeepalive 25 on the server for this peer — the server cannot reach the phone after the operator's NAT mapping changes, only the phone can recover by sending first. Thank you for AmneziaVPN!
Author
Owner

@papa-gadim commented on GitHub (Oct 20, 2026):

My connection also doesn’t reconnect after a period of inactivity, even though it’s active in the app. And sometimes it breaks completely.
Poco x8 pro android 16

<!-- gh-comment-id:6283287757 --> @papa-gadim commented on GitHub (Oct 20, 2026): My connection also doesn’t reconnect after a period of inactivity, even though it’s active in the app. And sometimes it breaks completely. Poco x8 pro android 16
Author
Owner

@Atossy commented on GitHub (Oct 20, 2026):

I'm having the exact same problem. Android 17, One UI 9.0.

<!-- gh-comment-id:6303346002 --> @Atossy commented on GitHub (Oct 20, 2026): I'm having the exact same problem. Android 17, One UI 9.0.
Author
Owner

@real-master commented on GitHub (Oct 21, 2026):

Exact the same problem! Foco F5 Xiaomi HyperOS 3.0.2.0

<!-- gh-comment-id:6324329907 --> @real-master commented on GitHub (Oct 21, 2026): Exact the same problem! Foco F5 Xiaomi HyperOS 3.0.2.0
Author
Owner

@AndreiKud commented on GitHub (Oct 25, 2026):

Same, manual reconnection is needed after idle. but I use AWG 2.0

<!-- gh-comment-id:6399166725 --> @AndreiKud commented on GitHub (Oct 25, 2026): Same, manual reconnection is needed after idle. but I use AWG 2.0
Author
Owner

@cyberianin commented on GitHub (Oct 31, 2026):

I can reproduce the issue described in #3304 primarily on my Xiaomi Android device. The VPN remains in the "Connected" state, but traffic stops passing completely. Manually disconnecting and reconnecting immediately restores connectivity.

I also experience the same symptoms on Windows 10, sometimes during active use rather than after a period of inactivity.

Additionally, my other Android device reproduces the sleep/resume failure described in #3255, particularly after overnight inactivity.

All three clients use the same self-hosted AmneziaWG server.

We have verified that the tunnel works normally under load, including successful handshakes, an MTU of 1376, and sustained data transfers. However, we have not yet captured server-side packet traces during an actual stall, so the root cause remains unconfirmed.

I am interested in investigating and contributing a proper client-side recovery mechanism, with stalled-handshake detection, Android Doze/network-state handling, bounded retries, and regression tests.

The two issues may share a recovery-layer defect, even if their immediate triggers differ.

<!-- gh-comment-id:6549146870 --> @cyberianin commented on GitHub (Oct 31, 2026): I can reproduce the issue described in #3304 primarily on my Xiaomi Android device. The VPN remains in the "Connected" state, but traffic stops passing completely. Manually disconnecting and reconnecting immediately restores connectivity. I also experience the same symptoms on Windows 10, sometimes during active use rather than after a period of inactivity. Additionally, my other Android device reproduces the sleep/resume failure described in #3255, particularly after overnight inactivity. All three clients use the same self-hosted AmneziaWG server. We have verified that the tunnel works normally under load, including successful handshakes, an MTU of 1376, and sustained data transfers. However, we have not yet captured server-side packet traces during an actual stall, so the root cause remains unconfirmed. I am interested in investigating and contributing a proper client-side recovery mechanism, with stalled-handshake detection, Android Doze/network-state handling, bounded retries, and regression tests. The two issues may share a recovery-layer defect, even if their immediate triggers differ.
Author
Owner

@papa-gadim commented on GitHub (Nov 2, 2026):

I solved the problem by installing VLESS)))

<!-- gh-comment-id:6576369208 --> @papa-gadim commented on GitHub (Nov 2, 2026): I solved the problem by installing VLESS)))
Sign in to join this conversation.
No labels
pull-request
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
amnezia-vpn/amnezia-client#3166
No description provided.