[bug] Android: Subnet access fails after running in the background or switching networks Android:后台运行或切换网络后,无法访问其他节点的子网
问题简要描述 / Brief Description
Problem / 问题描述
When using the official EasyTier Android APK, access to subnets advertised by other peers sometimes stops working after the app has been running in the background. This may be related to switching Wi-Fi networks or switching between Wi-Fi and mobile data.
使用 EasyTier 官方安卓 APK,后台运行一段时间后,有时无法访问其他节点发布的子网。可能与切换 Wi-Fi 或在 Wi-Fi 和移动网络之间切换有关。
Bringing the app to the foreground does not restore connectivity. Manually stopping and restarting the EasyTier network restores access.
重新打开 APP 不能恢复访问,手动停止并重新启动 EasyTier 组网后可以恢复。
环境信息 / Environment Information
略
节点配置 / Node Configurations
略
日志信息 / Log Information
略
重现步骤 / Reproduction Steps
Reproduction scenario / 问题复现过程
The issue is intermittent. The exact duration and network transition required to trigger it have not yet been determined.
该问题偶发,目前尚未确定触发所需的具体时长和网络切换条件。
Start an EasyTier network using the official Android APK. 使用官方安卓 APK 启动 EasyTier 组网。
Confirm that a service on a subnet advertised by another peer is accessible. 确认可以访问其他节点发布的子网中的服务。
Put EasyTier in the background and leave it running. 将 EasyTier 放到后台持续运行。
During this period, the phone may switch Wi-Fi networks or switch between Wi-Fi and mobile data. 期间手机可能切换 Wi-Fi,或在 Wi-Fi 与移动网络之间切换。
Access to the previously reachable subnet service stops working. 此前可以访问的子网服务变得无法访问。
Bring EasyTier to the foreground; access does not recover. 将 EasyTier 切回前台,访问仍未恢复。
Stop and restart the EasyTier network; access is restored. 停止并重新启动 EasyTier 组网后,访问恢复。
预期结果 / Expected Behavior
Expected behavior / 预期行为
EasyTier should recover automatically after network changes or VPN interface failures, without requiring a manual restart of the network.
网络切换或 VPN 接口异常后,EasyTier 应自动恢复,不需要手动重启组网。
额外信息 / Additional Context
Findings from source inspection / 代码走查发现
Inspected revision / 走查提交: 8d200c26d723e6f1e4a96938d13bdf23489f4dab
The following recovery gaps were found in the Android/mobile TUN lifecycle:
在 Android/mobile TUN 生命周期中发现以下恢复缺口:
The mobile TUN read task signals interface closure when it exits, but the mobile runtime does not consume that notification to recover the interface. 移动端 TUN 读取任务退出时会发出接口关闭通知,但移动端运行时没有消费该通知并恢复接口。
TUN write failures do not reliably transition the interface into a failure state that triggers recovery. TUN 写入失败后,没有可靠地进入可触发恢复的故障状态。
The Android service's running status does not reliably reflect whether the TUN forwarding path is healthy. Android 服务的运行状态不能可靠反映 TUN 转发链路是否正常。
The existing frontend-driven TUN descriptor handoff depends on JavaScript execution, which may be suspended while the app is in the background. 现有前端驱动的 TUN 描述符交接依赖 JavaScript 执行,而后台页面可能暂停执行。
Restarting the service without the original configuration can lose the intended VPN settings. 服务在缺少原始配置的情况下重启,可能丢失预期的 VPN 配置。
These findings identify a possible recovery failure path. They do not yet establish that TUN failure is the exact cause of the observed network-switching issue. EasyTier already has peer heartbeat and reconnection mechanisms.
以上发现指出了一条可能无法自动恢复的故障路径,但尚未确认实际网络切换后的断连就是由 TUN 故障引起。EasyTier 本身已有节点心跳和重连机制。
Suggested solution / 修复建议
Handle TUN closure notifications and read/write failures, clean up failed forwarding tasks, and persist the interface failure state. 处理 TUN 关闭通知及读写失败,清理失效转发任务,并保存接口故障状态。
Move VPN recovery and descriptor handoff into the native background lifecycle, so recovery does not depend on the WebView. 将 VPN 恢复和描述符交接纳入原生后台生命周期,避免恢复依赖 WebView。
Rebuild failed interfaces using the original IP, routes, DNS, MTU, and excluded-app configuration, then attach the replacement descriptor to the core. 使用原有 IP、路由、DNS、MTU 和排除应用配置重建故障接口,再将新描述符交给核心。
Rate-limit recovery retries and validate the instance ID and interface generation to prevent stale requests from affecting stopped or replacement instances. 限制恢复重试频率,并校验实例 ID 和接口代次,避免过期请求影响已停止或已替换的实例。
Preserve the complete configuration when Android restarts the service, and reject incomplete startup requests instead of creating a VPN with default settings. Android 重启服务时保留完整配置;拒绝参数不完整的启动请求,避免使用默认配置创建 VPN。
Physical-device testing is still needed to confirm whether this recovery path explains and resolves the reported connectivity loss.
仍需通过真机测试,确认上述故障路径是否能够解释并解决实际出现的断连问题。
Source: EasyTier/EasyTier