Expo LAN configuration doesn't work for New ReactNative Project

99封情书 提交于 2019-12-30 03:10:27

问题


I have seen similar questions on Stackoverflow but none sorted the problem. I have just created new ReactNative project from Expo desktop app. But I can not run it on my Android phone via QR code scan when Expo configuration is set to LAN mode. Which seems not accessible on my Android phone (looks like). My phone is on same Wifi network.

I have also tried to run Expo demo app by turning off Firewalls but still no success. I'm sure your one technical look might soft my issue.

Note: The Expo tunnel was down that's why it loaded in LAN mode. Few days ago I tried Tunnel mode which works. But, at that time too LAN didn't work. So may be any one can point me in right direction, so I can run it in LAN mode (being on Phone and Machine on same Wifi Network).


回答1:


Your Android phone is unable to reach the server as the virtual adapter network is being used as preferred subnet.

Increase the WiFi adapter priority and it should run fine. (Uncheck Automatic metric in Advanced Adapter settings and assign a lower number for interface metric). See this link: https://answers.microsoft.com/en-us/windows/forum/windows_10-networking/adapter-priority-setting-unavailable-in-windows-10/d2b63caa-e77c-4b46-88b5-eeeaee00c306?auth=1




回答2:


After struggling through the XDE Desktop app but no success. Finally decided to try the Expo CLI tool as mentioned here: https://expo.io/learn With few simple steps, it created 1st demo project for me.

And by following CLI command here: https://docs.expo.io/versions/latest/guides/exp-cli.html I am now able to run my first demo app with simple command e.g. exp start --dev --lan, which does the same job that XDE (Expo Desktop) app does of configuring settings to LAN and in Developer Mode.

I had gone through every possible solution but non worked for me to setup LAN connectivity, except the Expo CLI tool. Any one facing similar problems? Please go and give CLI a try. But make sure you check your Network Adapter priority settings (as VMWare/VBox network adapter's priority does create problem). As proposed by @mano.




回答3:


I had roughly this issue on my Ubuntu/Crouton setup and the problem there was that I had a local firewall blocking the port.

The fix there was to use iptables to open the port, like this:

$ sudo apt-get install iptables
$ sudo /sbin/iptables -I INPUT -p tcp --dport 19000 -j ACCEPT

More info here: https://github.com/dnschneid/crouton/wiki/Running-servers-in-crouton

I can imagine similar solutions might be needed on other platforms too.




回答4:


On OS X, it turned out that the firewall was blocking my 19000 port. Going to

Setting > Security & Privacy

and Turning firewall off solved it.




回答5:


FWIW, for me, I had set nodejs to "allow connections via private networks only", but my wifi network on my Windows machine was not set up as private. I changed it from public to private, restarted the app and then it worked fine.




回答6:


I had a same problem. You should turn off Firewall public or set inbound-outbound on the further. Hope that help you!




回答7:


In Windows 10 I had the same problem. I did these tasks: 1 - Change the priority of the network interfaces.

https://www.windowscentral.com/how-change-priority-order-network-adapters-windows-10

Before:Image1 After: Image2

The mobile and the computer must be on the same network (check the mask). In my case, Virtual Box changed the priorities.

2 - First I turned off the firewall and I check and saw the app was working then I did the correct adjustments to the firewall.

Hope that help you!




回答8:


I was somehow able to identify the problem. You just need to do ipconfig /all (windows) or ifconfig (unix) and check for Wireless LAN adapter WIFI IPV4 Address and replace the host in exp URL with it.

exp://192.168.84.161:19000 (This published URL on expo start was using ethernet IPV4 adress instead of Wireless LanIPV4 192.168.0.10)

Changing the host and directly hitting it on safari opens a expo app and loads the react app successfully

Hope this will help everyone facing this problem.




回答9:


In my case, I had Docker desktop client installed in my pc. I just uninstalled Docker from my pc and it's working! Maybe there was a better way than uninstall but I didn't need Docker so I uninstalled it.



来源:https://stackoverflow.com/questions/47966887/expo-lan-configuration-doesnt-work-for-new-reactnative-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!