capacitor-plugins icon indicating copy to clipboard operation
capacitor-plugins copied to clipboard

@capacitor/network reports "connected" as true when the device is offline. It happens when there is a VPN client running.

Open kpturner opened this issue 1 year ago • 10 comments

Plugin(s)

@capacitor/network

Capacitor Version

Latest Dependencies:

  @capacitor/cli: 5.5.1
  @capacitor/core: 5.5.1
  @capacitor/android: 5.5.1
  @capacitor/ios: 5.5.1

Installed Dependencies:

  @capacitor/cli: 5.5.0
  @capacitor/core: 5.5.0
  @capacitor/android: 5.5.0
  @capacitor/ios: 5.5.0

Platform(s)

Android IOS

Current Behavior

We have a weird situation where, on Android, the getStatus() method flip-flops between "connected=true" and "connected=false" randomly despite the device being completely offline (airplane mode). When it reports "connected=true" it states that the connection type is "unknown". It turns out that this is being caused by having a VPN client (in this case, NordLayer) installed and active. Although the device is offline, there is something about the VPN client that causes the plugin to think it is online - well it actually continuously toggles between online/offline.

Expected Behavior

Should not think its connected/online when it is not - even with a VPN client.

kpturner avatar Nov 24 '23 10:11 kpturner

same

loremru avatar Feb 26 '24 14:02 loremru

Hello, I have the same problem, did you manage to find a solution?

DanGosw avatar Apr 03 '24 00:04 DanGosw

Also just noticed this issue. on capacitor 6.

drakedeatonuk avatar Jun 22 '24 19:06 drakedeatonuk

@drakedeatonuk did you find any solution?

DanGosw avatar Jun 26 '24 13:06 DanGosw

Unfortunately I did not @DanGosw 😞 I would've told you if I had.

drakedeatonuk avatar Jun 26 '24 15:06 drakedeatonuk

@drakedeatonuk I found a possible solution, although very ugly, and it is to make requests from time to time to detect a connection, for example using axios, axios.get(https://pokeapi.co/api/v2/pokemon/)

and here I evaluate by the type of response that comes back to me, it may help you depending on your case

DanGosw avatar Jun 26 '24 15:06 DanGosw

same, using tailscale for vpn :/ (only happening on android)

karen1au avatar Jul 10 '24 19:07 karen1au

@karen1au Apparently this problem is in many other bookstores that offer the same thing :(

DanGosw avatar Jul 11 '24 13:07 DanGosw

Is it possible to delay any display or alert by x amount of seconds until the VPN kicks in? Then subscribe to the observable.

razmans avatar Jul 31 '24 08:07 razmans

Not sure what you mean by "VPN kicks in" in this scenario?

kpturner avatar Jul 31 '24 09:07 kpturner