WorkManager NetworkType.CONNECTED constraint met even if I disabled internet connectivity, while using VPN apps causing unexpected retry scheduling

huangapple go评论68阅读模式
英文:

WorkManager NetworkType.CONNECTED constraint met even if I disabled internet connectivity, while using VPN apps causing unexpected retry scheduling

问题

VPN应用似乎破坏了我的应用中WorkManager的NetworkType.CONNECTED约束。因为我已经明确设置了work manager请求的setRequiredNetworkType(NetworkType.CONNECTED)。但是,当我使用VPN应用并关闭互联网时,会被安排重试,并且即使互联网关闭,它仍然继续运行。通常,由于NetworkType.CONNECTED约束,如果关闭互联网,它就不应该运行。这是WorkManager的bug还是VPN应用的预期行为?

英文:

VPN applications seem to break WorkManager's NetworkType.CONNECTED constraint in my app. Because I have set setRequiredNetworkType(NetworkType.CONNECTED) of work manager request explicitly. However, when I'm using VPN apps and turn off the internet, Retry will be scheduled, and keeps on running even when internet is turned off. Normally, due to the NetworkType.CONNECTED constraint, it shouldn't run if internet is turned off. A bug from WorkManager or it's how supposed to be with VPN apps?

答案1

得分: 1

我认为这是WorkManager在这种情况下的正常行为,因为当VPN在您的设备上启动时,它会创建一个虚拟私人网络连接(显然),通过安全服务器路由所有网络流量。这可能会给人一种印象,即即使实际的网络连接(如Wi-Fi或移动数据)未激活,设备仍然在线。因此,即使物理网络连接被禁用,VPN连接仍然可能满足WorkManager的NetworkType.CONNECTED约束。

换句话说,如果您在VPN处于活动状态时禁用互联网访问,WorkManager可能仍然将VPN连接视为“已连接”,并可能继续重试具有NetworkType.CONNECTED的任务。

英文:

Okay, that's weird, but I think I got it 👀;

I think this is the normal behavior of the WorkManager in this case because when VPN starts in your device, it creates a virtual private network connection (obviously), which routes all network traffic through a secure server.

Which may provide the impression that the device is online even if the actual network connection (such as Wi-Fi or cellular data) is not active. As a result, even though the physical network connection is disabled, the VPN connection may still satisfy WorkManager's NetworkType.CONNECTED constraint.

In other words, if you disable internet access while a VPN is active, WorkManager may still regard the VPN connection as "connected" and may continue to retry tasks that have a NetworkType.CONNECTED.

huangapple
  • 本文由 发表于 2023年4月17日 16:11:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/76032984.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定