Search code examples
androidreact-nativenetwork-programmingexpoadb

standalone expo app with VPN turned on ( the VPN on android device ) - adb reverse tcp issue


I'm developing react native app with expo and I have the development build on android device works well but when I turn on VPN on the android device the app get disconnected to the metro , I need to keep app connected along with VPN turned on but how to do that ?

update

the result I get when try to start my app while vpn is on (on android device ) :

immediately i get error loading app ,connection reset, and i connot connect to the server at all .

and when I turn vpn on after my app get connected to the server ,

I'm getting in console :

Cannot connect to the Metro. Try the following to fix the issue:

Ensure that the Metro server is running and available on the same network Ensure that your device/emulator is connected to your machine and has USB debugging enabled - run 'adb devices' to see a list of connected devices

If you're on a physical device connected to the same machine, run 'adb reverse tcp:8081 tcp:8081' to forward requests from your device If your device is on the same Wi-Fi network, set 'Debug server host & port for device' in 'Dev settings' to your machine's IP address and the port of the local dev server - e.g. 10.0.1.1:8081

URL: 192.168.1.4:8081

what I tried update 2 after abundant research

1- enable USB debugging and connect device via usb

2- adb kill-server & adb start-server

3- adb tcpip 5555

4- disconnect usb

5- adb connect <phone's IP>

adb reverse successfully done ,I got connected to 192.168.1.3:5555

but when I run

npx expo start --localhost --android

[ADB] Couldn't reverse port 8081: adb.exe: error: more than one device/emulator

Environment :

Expo managed workflow sdk 50

OS: Windows 10

standalone app

I have a full internet access and the vpn on android and computer is psiphon


Solution

  • I got it fixed , it's just about the wrong port I was trying to use 'port 5555' , so I could make it work ,the steps as following :

    1_ enable USB debugging and connect device to the laptop via USB cable

    2- adb kill-server & adb start-server

    • daemon not running; starting now at tcp:5037
    • daemon started successfully

    3- adb tcpip 5037

    4- adb connect <phone's IP>

    5- adb kill-server

    6- npx expo start --localhost --android

    and it successfully worked .