[GH-ISSUE #3255] [Android] AmneziaWG with app split tunneling silently stops sending after Doze, shows "Connected" Туннель молча умирает после сна #1504

Open
opened 2026-10-13 20:43:56 +00:00 by bsakaguchi · 1 comment
Owner

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

🇷🇺 Русский

Describe the bug
На Android при раздельном туннелировании по приложениям (через VPN идут только выбранные приложения) туннель AmneziaWG «умирает» через несколько минут после выключения экрана. В приложении статус «Подключено», но выбранные приложения не получают трафик (все остальные работают). Сам туннель не восстанавливается даже через 40+ минут после пробуждения. Помогает только переподключение VPN или смена сети (Wi-Fi ↔ мобильная). Воспроизводится и на мобильной сети, и на длительном Wi-Fi. На Windows с тем же сервером и через тот же домашний канал проблемы нет вообще.

Замеры в момент сбоя показывают, что клиент перестаёт отправлять любые пакеты (включая keepalive), при этом сеть исправна.

To Reproduce

  1. Подключиться к своему серверу AmneziaWG (параметры по умолчанию, PersistentKeepalive 25–35).
  2. Включить раздельное туннелирование по приложениям, режим «только выбранные приложения через VPN» (выбрано 9 приложений).
  3. Выключить экран и оставить телефон на ~5–15 минут (достаточно для лёгкого Doze).
  4. Разблокировать и открыть любое приложение из списка — связи нет, статус по-прежнему «Подключено».

Expected behavior
После пробуждения клиент должен возобновить отправку (keepalive / новое рукопожатие) и туннель должен снова заработать — или хотя бы показать, что соединение разорвано.

Log files
Что удалось измерить в момент сбоя:

  1. awg show на сервере: последнее рукопожатие пира телефона совпадает (с точностью до минуты) с переходом телефона в light Doze (dumpsys deviceidle → Idling history: light-idle). После этого — ни одного пакета.
  2. tcpdump на сервере по порту AWG во время активного использования приложений из списка: 0 пакетов от телефона за 40 секунд. Пир с Windows в это же время нормально обменивается трафиком.
  3. adb shell ping <сервер> — проходит, 0% потерь.
  4. adb shell "echo hi | nc -u -w 2 <сервер> <порт AWG>" — пакет доходит до сервера (виден в tcpdump). То есть UDP с телефона на этот порт сеть не блокирует.
  5. /proc/net/udp: UDP-сокет процесса Амнезии существует, drops = 0, tx_queue = 0. Сокеты выбранных приложений висят на адресе туннеля (10.8.1.x) и шлют в туннель DNS-запросы.
  6. /proc/net/dev: за ~20 секунд использования приложений TX на tun-интерфейсе растёт (+37 пакетов), RX — 0. Процессы org.amnezia.vpn и :amneziaAwgService живы, foreground service не перезапускался, правила ip rule с uidrange для туннеля на месте.
  7. Амнезия исключена из оптимизации батареи: standby bucket = EXEMPTED (5), в whitelist Doze; netpolicy не показывает блокировок для её UID.

Могу снять debug logcat / dumpsys — подскажите, что нужно.

Screenshots
—

Desktop:

  • OS: Windows 11 (не затронут, использовался для сравнения)
  • Version: [версия AmneziaVPN на ПК]

Smartphone:

  • Device: Infinix note 30
  • OS: Android 14
  • Version: [5.0.3.0]

Server:

  • OS: Ubuntu 22.04, AmneziaWG в Docker (установлен через приложение AmneziaVPN)

Additional context

  • Триггер — уход устройства в Doze (даже лёгкий).
  • Возможно связано: #2155 (раздельное туннелирование по приложениям молча перестаёт работать при статусе «активно»), #3084 (таймеры Go на CLOCK_MONOTONIC во время сна). Но в отличие от #3084, здесь туннель не восстанавливается через минуту — он не восстанавливается вообще, пока не переподключить вручную.

🇬🇧 English

Describe the bug
On Android with app-based split tunneling (only selected apps go through VPN), the AmneziaWG tunnel silently dies a few minutes after the screen turns off. The app keeps showing "Connected", but the selected apps get no traffic (all other apps work fine). The tunnel never recovers by itself — even 40+ minutes after waking the phone. Only reconnecting the VPN or switching network (Wi-Fi ↔ mobile) fixes it. Happens on mobile data and on long-lived Wi-Fi. On Windows, with the same server and the same home connection, the problem never occurs.

Measurements taken during the failure show the client stops sending any packets (including keepalives) while the network itself is fine.

To Reproduce

  1. Connect to a self-hosted AmneziaWG server (default parameters, PersistentKeepalive 25–35).
  2. Enable split tunneling by apps, mode "only selected apps through VPN" (9 apps selected).
  3. Turn the screen off and leave the phone for ~5–15 minutes (enough for light Doze).
  4. Unlock and open any app from the list — no connectivity, status still "Connected".

Expected behavior
After the device wakes up, the client should resume sending (keepalive / new handshake) and the tunnel should work again, or at least show that it is disconnected.

Log files
What I measured at the moment of failure:

  1. awg show on the server: the phone peer's latest handshake matches (within a minute) the moment the phone entered light Doze (dumpsys deviceidle → Idling history: light-idle). No packets after that.
  2. tcpdump on the server on the AWG port while actively using apps from the list: 0 packets from the phone in 40 s. The Windows peer exchanges traffic normally at the same time.
  3. adb shell ping <server> — works, 0% loss.
  4. adb shell "echo hi | nc -u -w 2 <server> <awg port>" — the packet reaches the server (seen in tcpdump). So UDP from the phone to this port is not blocked by the network.
  5. /proc/net/udp: the Amnezia process UDP socket exists, drops = 0, tx_queue = 0. Sockets of the selected apps are bound to the tunnel address (10.8.1.x) and send DNS queries into the tunnel.
  6. /proc/net/dev: during ~20 s of app usage, TX on the tun interface grows (+37 packets), RX stays at 0. Processes org.amnezia.vpn and :amneziaAwgService are alive, the foreground service was not restarted, ip rule uidrange rules for the tunnel are in place.
  7. Amnezia is exempt from battery optimization: standby bucket = EXEMPTED (5), in the Doze whitelist; netpolicy shows no blocking for its UID.

I can provide debug logcat / dumpsys output if you tell me what is needed.

Screenshots
N/A

Desktop:

  • OS: Windows 11 (not affected, used for comparison)
  • Version: [AmneziaVPN version on PC]

Smartphone:

  • Device: Infinix note 30
  • OS: Android 14
  • Version: [5.0.3.0]

Server:

  • OS: Ubuntu 22.04, AmneziaWG in Docker (installed via the AmneziaVPN app)

Additional context

  • Trigger seems to be the device entering Doze (even light Doze).
  • Possibly related: #2155 (app split tunneling silently stops while status is "active"), #3084 (Go timers on CLOCK_MONOTONIC during sleep). But unlike #3084, here the tunnel does not recover after a minute — it never recovers until manual reconnect.
Originally created by @strateg369 on GitHub (Oct 3, 2026). Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/3255 ## 🇷🇺 Русский **Describe the bug** На Android при раздельном туннелировании по приложениям (через VPN идут только выбранные приложения) туннель AmneziaWG «умирает» через несколько минут после выключения экрана. В приложении статус «Подключено», но выбранные приложения не получают трафик (все остальные работают). Сам туннель не восстанавливается даже через 40+ минут после пробуждения. Помогает только переподключение VPN или смена сети (Wi-Fi ↔ мобильная). Воспроизводится и на мобильной сети, и на длительном Wi-Fi. На Windows с тем же сервером и через тот же домашний канал проблемы нет вообще. Замеры в момент сбоя показывают, что клиент перестаёт отправлять любые пакеты (включая keepalive), при этом сеть исправна. **To Reproduce** 1. Подключиться к своему серверу AmneziaWG (параметры по умолчанию, PersistentKeepalive 25–35). 2. Включить раздельное туннелирование по приложениям, режим «только выбранные приложения через VPN» (выбрано 9 приложений). 3. Выключить экран и оставить телефон на ~5–15 минут (достаточно для лёгкого Doze). 4. Разблокировать и открыть любое приложение из списка — связи нет, статус по-прежнему «Подключено». **Expected behavior** После пробуждения клиент должен возобновить отправку (keepalive / новое рукопожатие) и туннель должен снова заработать — или хотя бы показать, что соединение разорвано. **Log files** Что удалось измерить в момент сбоя: 1. `awg show` на сервере: последнее рукопожатие пира телефона совпадает (с точностью до минуты) с переходом телефона в light Doze (`dumpsys deviceidle` → Idling history: light-idle). После этого — ни одного пакета. 2. `tcpdump` на сервере по порту AWG во время активного использования приложений из списка: **0 пакетов от телефона** за 40 секунд. Пир с Windows в это же время нормально обменивается трафиком. 3. `adb shell ping <сервер>` — проходит, 0% потерь. 4. `adb shell "echo hi | nc -u -w 2 <сервер> <порт AWG>"` — **пакет доходит до сервера** (виден в tcpdump). То есть UDP с телефона на этот порт сеть не блокирует. 5. `/proc/net/udp`: UDP-сокет процесса Амнезии существует, drops = 0, tx_queue = 0. Сокеты выбранных приложений висят на адресе туннеля (10.8.1.x) и шлют в туннель DNS-запросы. 6. `/proc/net/dev`: за ~20 секунд использования приложений TX на tun-интерфейсе растёт (+37 пакетов), RX — 0. Процессы `org.amnezia.vpn` и `:amneziaAwgService` живы, foreground service не перезапускался, правила `ip rule` с uidrange для туннеля на месте. 7. Амнезия исключена из оптимизации батареи: standby bucket = EXEMPTED (5), в whitelist Doze; netpolicy не показывает блокировок для её UID. Могу снять debug logcat / dumpsys — подскажите, что нужно. **Screenshots** — **Desktop:** - OS: Windows 11 (не затронут, использовался для сравнения) - Version: [версия AmneziaVPN на ПК] **Smartphone:** - Device: Infinix note 30 - OS: Android 14 - Version: [5.0.3.0] **Server:** - OS: Ubuntu 22.04, AmneziaWG в Docker (установлен через приложение AmneziaVPN) **Additional context** - Триггер — уход устройства в Doze (даже лёгкий). - Возможно связано: #2155 (раздельное туннелирование по приложениям молча перестаёт работать при статусе «активно»), #3084 (таймеры Go на CLOCK_MONOTONIC во время сна). Но в отличие от #3084, здесь туннель не восстанавливается через минуту — он не восстанавливается вообще, пока не переподключить вручную. --- ## 🇬🇧 English **Describe the bug** On Android with app-based split tunneling (only selected apps go through VPN), the AmneziaWG tunnel silently dies a few minutes after the screen turns off. The app keeps showing "Connected", but the selected apps get no traffic (all other apps work fine). The tunnel never recovers by itself — even 40+ minutes after waking the phone. Only reconnecting the VPN or switching network (Wi-Fi ↔ mobile) fixes it. Happens on mobile data and on long-lived Wi-Fi. On Windows, with the same server and the same home connection, the problem never occurs. Measurements taken during the failure show the client stops sending any packets (including keepalives) while the network itself is fine. **To Reproduce** 1. Connect to a self-hosted AmneziaWG server (default parameters, PersistentKeepalive 25–35). 2. Enable split tunneling by apps, mode "only selected apps through VPN" (9 apps selected). 3. Turn the screen off and leave the phone for ~5–15 minutes (enough for light Doze). 4. Unlock and open any app from the list — no connectivity, status still "Connected". **Expected behavior** After the device wakes up, the client should resume sending (keepalive / new handshake) and the tunnel should work again, or at least show that it is disconnected. **Log files** What I measured at the moment of failure: 1. `awg show` on the server: the phone peer's latest handshake matches (within a minute) the moment the phone entered light Doze (`dumpsys deviceidle` → Idling history: light-idle). No packets after that. 2. `tcpdump` on the server on the AWG port while actively using apps from the list: **0 packets from the phone** in 40 s. The Windows peer exchanges traffic normally at the same time. 3. `adb shell ping <server>` — works, 0% loss. 4. `adb shell "echo hi | nc -u -w 2 <server> <awg port>"` — **the packet reaches the server** (seen in tcpdump). So UDP from the phone to this port is not blocked by the network. 5. `/proc/net/udp`: the Amnezia process UDP socket exists, drops = 0, tx_queue = 0. Sockets of the selected apps are bound to the tunnel address (10.8.1.x) and send DNS queries into the tunnel. 6. `/proc/net/dev`: during ~20 s of app usage, TX on the tun interface grows (+37 packets), RX stays at 0. Processes `org.amnezia.vpn` and `:amneziaAwgService` are alive, the foreground service was not restarted, `ip rule` uidrange rules for the tunnel are in place. 7. Amnezia is exempt from battery optimization: standby bucket = EXEMPTED (5), in the Doze whitelist; netpolicy shows no blocking for its UID. I can provide debug logcat / dumpsys output if you tell me what is needed. **Screenshots** N/A **Desktop:** - OS: Windows 11 (not affected, used for comparison) - Version: [AmneziaVPN version on PC] **Smartphone:** - Device: Infinix note 30 - OS: Android 14 - Version: [5.0.3.0] **Server:** - OS: Ubuntu 22.04, AmneziaWG in Docker (installed via the AmneziaVPN app) **Additional context** - Trigger seems to be the device entering Doze (even light Doze). - Possibly related: #2155 (app split tunneling silently stops while status is "active"), #3084 (Go timers on CLOCK_MONOTONIC during sleep). But unlike #3084, here the tunnel does not recover after a minute — it never recovers until manual reconnect.
Author
Owner

@dofamin9 commented on GitHub (Oct 6, 2026):

Device: Redmi K30S
OS: Android 15(crDroid 11.8)
Amnezia Version: [5.0.3.0]

Server:
OS: Debain13, AmneziaWG3.1 (installed via the AmneziaVPN app)

Раздельное туннелирование по приложению, тоже самое поведение/Per app split-tunneling, the same behavior.

<!-- gh-comment-id:6013424888 --> @dofamin9 commented on GitHub (Oct 6, 2026): Device: Redmi K30S OS: Android 15(crDroid 11.8) Amnezia Version: [5.0.3.0] Server: OS: Debain13, AmneziaWG3.1 (installed via the AmneziaVPN app) Раздельное туннелирование по приложению, тоже самое поведение/Per app split-tunneling, the same behavior.
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#1504
No description provided.