I recently started using expo with WSL2, and want to connect a physical device to expo. The tunnel option works, but is slow and impossible to use with a debugger. I’d like to be able to connect directly with a device on the same wifi network.
There are some problems with the networking configuration in WSL2, but I’ve been able to overcome them when using a python webserver. If I do the following:
netsh interface portproxy add v4tov4 listenport=19000 listenaddress=0.0.0.0 connectport=19000 connectaddress=127.0.0.1
netsh advfirewall firewall add rule name="TCP Port Open" dir=in action=allow protocol=TCP localport=19000
python3 -m http.server 19000
Then I am able to access the following:
192.168.1.3:19000 (windows ip, from same machine)
192.168.1.3:19000 (from external device on same lan network)
However, when I run
expo start I can only access from localhost. Now, I noticed that expo by default binds to the local WSL ip, while the python command binds to 0.0.0.0
So I tried
export env REACT_NATIVE_PACKAGER_HOSTNAME=0.0.0.0
Now, expo starts on the same ip and port as the python command, but I am still unable to connect to expo. Is there something I’m missing in how it binds to the address?
One thing I noticed is
ss -tulw prints
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port tcp LISTEN 0 128 *:19000 *:*
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port tcp LISTEN 0 5 0.0.0.0:19000 0.0.0.0:*
I’d really like to get expo working smoothly with WSL2 so that I can debug properly, so if anyone has suggestions I’d greatly appreciate it!
Expo CLI 3.21.5 environment info: System: OS: Linux 4.19 Ubuntu 18.04.4 LTS (Bionic Beaver) Shell: 4.4.20 - /bin/bash Binaries: Node: 14.3.0 - ~/.nvm/versions/node/v14.3.0/bin/node Yarn: 1.12.3 - /usr/bin/yarn npm: 6.14.5 - ~/.nvm/versions/node/v14.3.0/bin/npm npmPackages: expo: ^37.0.12 => 37.0.12 react: 16.9.0 => 16.9.0 react-dom: 16.9.0 => 16.9.0 react-native: https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz => 0.61.4 react-native-web: ~0.11.7 => 0.11.7 react-navigation: ^4.3.9 => 4.3.9 npmGlobalPackages: expo-cli: 3.21.5