Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtualbox related issue - multiple networks #60

Closed
xingjianpan opened this issue Mar 14, 2017 · 24 comments
Closed

Virtualbox related issue - multiple networks #60

xingjianpan opened this issue Mar 14, 2017 · 24 comments

Comments

@xingjianpan
Copy link

xingjianpan commented Mar 14, 2017

Hi,

I have virtual box installed on my system and there are multiple networks available in additional to my WIFI network (i.e VirtualBox Host-Only Network, VirtualBox Host-Only Network #2, VirtualBox Host-Only Network #3 , etc..).

After running the command yarn start, i got below messsage:

Or enter this address in the Expo app's search bar:

exp://192.168.56.12:19000

Initially i was not able to connect to this address using Expo App. After quite some time investigating this issue, i noticed it's because 192.168.56.12 belongs to one of the network created by VirtualBox.

After disabling all the networks created by Virtual Box, I am able to connect Expo with my project.
and the message become this. Note 192.168.1.12 belongs to my WIFI network which my phone can connect.

Or enter this address in the Expo app's search bar:

exp://192.168.1.12:19000

So, is this a bug? or is there a place where i can set which network to use?

@anp
Copy link
Contributor

anp commented Mar 14, 2017

I think this is probably a bug. What OS are you using? I suspect that our detection for "default network device" is not producing the correct result here. We currently use https://www.npmjs.com/package/ip to detect IP addresses, but it might be worth trying with https://www.npmjs.com/package/address or another package.

cc @jesseruder, relevant xdl line: https://github.com/exponent/xdl/blob/43f29f10ea1641a5ab1808af93bedb8ee683a6b8/src/UrlUtils.js#L148

@xingjianpan
Copy link
Author

my system is Windows 10 Home Edition.

@anp
Copy link
Contributor

anp commented Mar 15, 2017

This issue has been open for a while indutny/node-ip#21. I'm going to see if I can repro this and will check if the address package works better in this scenario.

@anp
Copy link
Contributor

anp commented Mar 16, 2017

Can you tell me what the output of this command is in a node REPL when running virtualbox on this machine?

Object.keys(require('os').networkInterfaces()).reduce((results, name) => results.concat(interfaces[name]), []).filter((iface) => iface.family === 'IPv4' && !iface.internal).map((iface) => iface.address)

@xingjianpan
Copy link
Author

xingjianpan commented Mar 16, 2017

I got below error when running your command:

ReferenceError: interfaces is not defined
at Object.keys.reduce (repl:1:89)
at Array.reduce (native)
at repl:1:48
at sigintHandlersWrap (vm.js:22:35)
at sigintHandlersWrap (vm.js:96:12)
at ContextifyScript.Script.runInThisContext (vm.js:21:12)
at REPLServer.defaultEval (repl.js:346:29)
at bound (domain.js:280:14)
at REPLServer.runBound [as eval] (domain.js:293:12)
at REPLServer. (repl.js:545:10)

However, if i just run the first part of your command:

require('os').networkInterfaces()

I got below results:

{ 'VirtualBox Host-Only Network':
[ { address: 'fe80::787d:2d70:287f:b786',
netmask: 'ffff:ffff:ffff:ffff::',
family: 'IPv6',
mac: '0a:00:27:00:00:06',
scopeid: 6,
internal: false },
{ address: '192.168.56.1',
netmask: '255.255.255.0',
family: 'IPv4',
mac: '0a:00:27:00:00:06',
internal: false } ],
'VirtualBox Host-Only Network #2':
[ { address: 'fe80::84af:8a25:b53a:67f9',
netmask: 'ffff:ffff:ffff:ffff::',
family: 'IPv6',
mac: '0a:00:27:00:00:17',
scopeid: 23,
internal: false },
{ address: '192.168.25.2',
netmask: '255.255.255.0',
family: 'IPv4',
mac: '0a:00:27:00:00:17',
internal: false } ],
'VirtualBox Host-Only Network #3':
[ { address: 'fe80::b9e5:1022:96dc:3786',
netmask: 'ffff:ffff:ffff:ffff::',
family: 'IPv6',
mac: '0a:00:27:00:00:15',
scopeid: 21,
internal: false },
{ address: '192.168.99.1',
netmask: '255.255.255.0',
family: 'IPv4',
mac: '0a:00:27:00:00:15',
internal: false } ],
MyWLAN:
[ { address: 'fe80::55f8:45e1:8a5e:a510',
netmask: 'ffff:ffff:ffff:ffff::',
family: 'IPv6',
mac: '34:f3:9a:64:28:5f',
scopeid: 8,
internal: false },
{ address: '192.168.1.11',
netmask: '255.255.255.0',
family: 'IPv4',
mac: '----removed----',
internal: false } ],
'Loopback Pseudo-Interface 1':
[ { address: '::1',
netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff',
family: 'IPv6',
mac: '00:00:00:00:00:00',
scopeid: 0,
internal: true },
{ address: '127.0.0.1',
netmask: '255.0.0.0',
family: 'IPv4',
mac: '00:00:00:00:00:00',
internal: true } ] }

@smiled0g
Copy link

@xingjianpan I was having the same problem. Assigning interface matric (priority) for your Wifi adapter and any other network adapters solves the problem for me. The order of IP used in https://www.npmjs.com/package/ip seems to be the first one you can see when running ipconfig.

This link shows how: https://answers.microsoft.com/en-us/windows/forum/windows_10-networking/adapter-priority-setting-unavailable-in-windows-10/d2b63caa-e77c-4b46-88b5-eeeaee00c306

Hope this helps

@xingjianpan
Copy link
Author

xingjianpan commented Mar 17, 2017

@smiled0g , many thanks! I will try it out.

@smiled0g , this method works for me! Thanks!

@digital-stoic
Copy link

Hi guys,

I think the proper way to address this issue is simply to be able to specify IP and port at launch (options, environment variables).

Here is the problem that I have related to this open issue:

  • My expo App runs in a Docker container => many options possible for the interfaces (bridges, overlay networks...)
  • My server running the docker has a virtual public IP (behind load balancer) => Neither the container nor the server is 'aware' of this IP

=> The only way to address this and ALL the other possible networking configurations is to be able to setup the IP+Port at the application level (Expo)

Cheers,

@pstanton
Copy link

adapter ordering is a work around, a solution would be to be able to configure.

@Himujjal
Copy link

The following steps will definitely help. I had the same problem and was able to solve it in my Windows 10 OS. I had Virtual Box installed on my computer and I was not able to run CRNA in my android expo client. So,

  1. first I connected my laptop through my mobile hotspot.
  2. Then Control Panel > (search for 'network connections') > network connections
  3. Right-Click on 'Wifi' > select 'Properties' > 'Internet Protocol Version 4 (TCP/IPv4)' [don't uncheck the mark]
  4. Go to "Properties" > "Advanced..." > (Uncheck 'Automatic Metric') > Type in the text-box below that (Interface Metric) : 10.
  5. Click OK and OK and OK :)
  6. Then do the same for the other "Virtual Box-xxxxx" networks. But instead put 20 in the Interface Metric text-box.
  7. Click OK, OK and OK.
  8. Try restarting your app on Expo. It must work now!

@rottenoats
Copy link

I had a similar issue as @Himujjal . I had VMWare installed. Going to network connections and deactivating all of them solved the problem.

@clarkgrg
Copy link

I couldn't get the above items to work. Although my problem is running Hyper-V. I just disabled the Ethernet connection for Hyper-V while running react-native.

@andriy-f
Copy link

If you set env var REACT_NATIVE_PACKAGER_HOSTNAME to desired IP, then it will use that address. More info here https://github.com/react-community/create-react-native-app/blob/master/react-native-scripts/template/README.md#configuring-packager-ip-address

@webprofusion-chrisc
Copy link

For info, other tools like Ionic let you choose which network interface to serve from.

For windows, running SET REACT_NATIVE_PACKAGER_HOSTNAME=192.168.1.5 in the terminal (or permanently in the environment variable settings) is the best option, much more so that messing with your adapter settings.

@spyp
Copy link

spyp commented Jan 20, 2018

Hey all and thxn @smiled0g i think this comment should be added in docs many of us using windows and we have problem
tnx again my problem is solved too

@Bryze
Copy link

Bryze commented Feb 19, 2018

@webprofusion-chrisc
Even though I have updated both the current CMD session and the registry by using
set REACT_NATIVE_PACKAGER_HOSTNAME=192.168.0.96 and setx REACT_NATIVE_PACKAGER_HOSTNAME 192.168.0.96. Doing a yarn start displays the ip exp://192.168.56.1:19000 which is my VirtualBox Ip.

Additionally, doing a ls env: on PowerShell shows me ->
image

Also, here is my ipconfig
image

Are there any additional settings that need to be changed?

EDIT
Was a restart issue. Now, yarn start was picking up the new environment variable value.

@webprofusion-chrisc
Copy link

@Bryze actually I haven't seen 'setx' before, you learn something new every day. The conventional way is to go to Control Panel\System and Security\System > Advanced system settings, then Environment Variables, you can then set the variable at the user or system level. You then need to close and reopen the command window you're working in (or any other dependant processes which spawned before you changed it).

@Bryze
Copy link

Bryze commented Feb 20, 2018

@webprofusion-chrisc yes indeed that's the conventional way. I had some doubts settings environment variables as all I could see in it were paths. So that confused me a little bit.

However, FYI when we do setx places them in the environment variables section. So, after using setx, if you head over to the same window via the conventional way, you'll see your newly set variable there! :)

@kajmagnus
Copy link

Don't forget to open the required firewall ports too on your laptop; in my case, seems to be 19000 and 19001.
(Right?)

@GBurgardt
Copy link

GBurgardt commented Mar 26, 2018

In my case (Ubuntu) the problem was always the ports.

To open them, these are the commands:

sudo ufw enable

sudo ufw allow 19000

sudo ufw allow 19001

@SirPhemmiey
Copy link

Had the same issue. Re-installing the Expo app on my device, and restarting (clear cache) the packager did it. Relieved!

@buryo
Copy link

buryo commented Nov 7, 2022

I had the same problem, then I realized my WIFI automatically connected to my neighbours. Your PC and phone should be on the same network.

@hafizip00
Copy link

The following steps will definitely help. I had the same problem and was able to solve it in my Windows 10 OS. I had Virtual Box installed on my computer and I was not able to run CRNA in my android expo client. So,

  1. first I connected my laptop through my mobile hotspot.
  2. Then Control Panel > (search for 'network connections') > network connections
  3. Right-Click on 'Wifi' > select 'Properties' > 'Internet Protocol Version 4 (TCP/IPv4)' [don't uncheck the mark]
  4. Go to "Properties" > "Advanced..." > (Uncheck 'Automatic Metric') > Type in the text-box below that (Interface Metric) : 10.
  5. Click OK and OK and OK :)
  6. Then do the same for the other "Virtual Box-xxxxx" networks. But instead put 20 in the Interface Metric text-box.
  7. Click OK, OK and OK.
  8. Try restarting your app on Expo. It must work now!

It's not working for me can you help me out @Himujjal please I'm struggling with this issue since last week.

@aalee-haider
Copy link

I had the same problem, then I realized my WIFI automatically connected to my neighbours. Your PC and phone should be on the same network.

I tried the same thing and it worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests