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

development server is not started while scanning the QR code in Expo client application #270

Closed
San10694 opened this issue Jun 21, 2017 · 30 comments

Comments

@San10694
Copy link

San10694 commented Jun 21, 2017

Description

I recently started to learn React-Native and created a CRNA project.
whenever I scan the QR code in Expo App , the application is not started on my android device though my mobile is connected to same wireless network as my PC (windows)

Expected Behavior

I tried to run "npm start" in command line.code compiled successfully and QR code generated in command line.Whenever I scan this code through Expo app it is not starting my apllication in android device.

Observed Behavior

I got following error

Something went wrong.
could not load exp://192.168.*.**:19000. Network response timed out.
error-log---
uncaught error:java.net.SocketTimeoutException: failed to connect to /192.168.*.**(port 19000) after 10000ms 

Environment

  • react-native-scripts:--react-native-scripts@0.0.31
  • react-native:-- react-native@0.44.3
  • expo:-- expo@17.0.0
  • node -v:v6.10.1
  • npm -v:3.10.10
  • yarn --version:N/A
  • watchman version:
  1. Operating system:windows-10
  2. Phone/emulator/simulator & version:android v 6.0
@danielkcz
Copy link

danielkcz commented Jun 25, 2017

Hey, I am trying very same thing and failing with same error as well. Here are the versions in my case. I am really just starting to know React Native. I haven't done any change there, just clean run of create-react-native-app (no errors during that).

react-native-scripts@0.0.40
react-native@0.45.1
expo@18.0.4
node@6.10.1
npm@3.10.10
yarn@0.24.6

Windows 10 Pro x64
Android 6.0 (LG G3)

Tried disabling Firewall it case it's blocked there, but no luck. I don't have any active antivirus protection.

@danielkcz
Copy link

danielkcz commented Jun 25, 2017

Found a troubleshooting section in readme on this and tried http access. This works and yields this result

// 20170625170940
// http://10.0.75.1:19000/

{
  "sdkVersion": "18.0.0",
  "name": "mapper",
  "slug": "mapper",
  "version": "0.1.0",
  "xde": true,
  "developer": {
    "tool": "crna"
  },
  "packagerOpts": {
    "hostType": "tunnel",
    "lanType": "ip",
    "dev": true,
    "strict": false,
    "minify": false,
    "urlType": "exp",
    "urlRandomness": null
  },
  "env": {
    
  },
  "bundleUrl": "http://10.0.75.1:19001/./node_modules/react-native-scripts/build/bin/crna-entry.bundle?platform=ios&dev=true&strict=false&minify=false&hot=false&assetPlugin=expo/tools/hashAssetFiles",
  "debuggerHost": "10.0.75.1:19001",
  "mainModuleName": "./node_modules/react-native-scripts/build/bin/crna-entry",
  "logUrl": "http://10.0.75.1:19000/logs",
  "id": "@anonymous/mapper-183ba25c-82ec-44fa-835f-05f67178c163"
}

On the same address but 19001 port there is only a message React Native packager is running..

Trying to access same address on the phone doesn't work, it cannot connect. I also tried connecting my computer to a wifi hotspot created on the phone. Same result.

Also noticed the url http://10.0.75.1:19000/logs in the output above, but that doesn't work either (on a computer).

Honestly, I don't think that IP address is a correct one there. I am not sure how is that obtained, but my network runs on regular 192.168.0.XXX addresses. How can my phone find that IP address?

@San10694
Copy link
Author

San10694 commented Jun 26, 2017

@FredyC I got an alternative for same problem
please download "Expo XDE" (desktop application) it will definately solve your problem.
following steps you need to follow
1-download Expo XDE for your appropriate OS(ie. windows or mac) from https://expo.io/
2-open Expo XDE and you will find your CRNA project , click on specific project you want to run ,,
3- click on the gear icon in address bar and select host as a Lan , here you will find your "ipAddress:host"
paste this address to your expo mobile App in explore section
and if everything is right then you will get your application running on your mobile .....
hope it will help you

@San10694
Copy link
Author

thanks @brentvatne,
but unfortunately I got same error after setting enviornment variables. Only solution I got so for is to run my CRNA app in "Expo XDE" as I explained in my above comment .
thanks for the help buddy

@danielkcz
Copy link

danielkcz commented Jun 29, 2017

Ok, I think I've found the culprit. I have a Docker installed which has its own network adapter. For some reason the Expo picks this virtual network over the real one. Using env variable as @brentvatne suggested works, but it's totally cumbersome solution.

I am wondering if this could be somehow configurable per project.

@ide
Copy link
Member

ide commented Jun 29, 2017

@FredyC One thing that might achieve a lot of what you are looking for is to use direnv (https://direnv.net). When you have direnv installed on your computer and set up in your shell profile, it will check for a file called .envrc, which is just a Bash script, in every directory you cd into.

So you could make a file at ~/your-project/.envrc with export REACT_NATIVE_PACKAGER_HOSTNAME=$(hostname) and it would apply only when your terminal is in your project directory (or one of its subdirectories).

@ahmetkakici
Copy link

Today i got the same error (Network response timed out.) also couldn't access packager's address from iphone's browser.
The problem was packager gets the first network adapter's local address (for me it was virtual-box adapter) 192.168.56.1 but my wireless network's local address was 192.168.1.28
So instead of scanning url, i manually entered exp://192.168.1.28 to expo ios-app and it worked.

@danielkcz
Copy link

Yea, in the end, I've solved the problem by changing priorities of my network adapters so the one I want is a first one. Works like magic :)

@danielkcz
Copy link

danielkcz commented Jun 30, 2017

Anyway, in my opinion, this should be solved on the Expo side to allow to pick which adapter to use. It's not always feasible to switch adapters priorities, in particular for people moving between e.g. wifi and wired connection.

@brentvatne
Copy link
Member

@FredyC - I don't know much about network adapter priorities and have never encountered this issue myself -- would you be interested in helping us handle this on the Expo side?

@danielkcz
Copy link

danielkcz commented Jun 30, 2017

@brentvatne Sure thing, just let me know what do you need from me. I am not sure about the way how Expo is finding that IP address. If you have access to a list of adapters of there is some high-level API only.

@GJS153
Copy link

GJS153 commented Jul 6, 2017

I have tried all the suggestions listed above, but none of them worked. Here the error message that I got on my phone: "Uncaught Error: java.net.SocketTimeoutException:connect timed out"
Could someone help me out?

@brentvatne
Copy link
Member

@FredyC - it just uses the ip node package -- ip.address() -- https://github.com/expo/xdl/blob/1e3f6637244b112a23963294f71a6a8d2e1b55c8/src/UrlUtils.js#L222

@danielkcz
Copy link

@brentvatne Ok, I see. The ip.address() allows specifying the name of the network adapter in a first argument. So if Expo can read that optionally from some config, it could solve all problems.

@davidsickmiller
Copy link

davidsickmiller commented Jul 28, 2017

I ran into this problem today, and then this github issue. It might be helpful to realize there are two facets to the multiple IP address situation.

The first facet is what IP address the server is listening on. Via netstat -an, you can see that the server is listing on all of the computer's IP addresses:
Proto Local Address Foreign Address State
TCP [::]:19000 [::]:0 LISTENING
TCP [::]:19001 [::]:0 LISTENING

So that facet seems solved already.

The second facet is which IP address to tell the user to type into Expo (or to transmit via the QR code). This is a more difficult problem, because you don't know for sure how the user has configured their network.

Idea 1: If you're on Windows and can access its details for each network adapter, you could guess that the user's phone is probably on a "Wireless LAN adapter" rather than an "Ethernet adapter".

Idea 2: Since QR codes have the capacity for 406 bytes, you could transmit an array of IP addresses, and the app can try each of them until it finds one that works.

Idea 3: Use a different protocol that does some sort of subnet broadcast.

@devWebNuts
Copy link

Thanks @ahmetkakici . That worked for me :-)

@anp
Copy link
Contributor

anp commented Oct 17, 2017

@davidsickmiller I agree that some of these solutions would be very good. Implementing any of them will require some effort on the Expo client side, and we're tracking that work over there.

Until we have these network reliability features impl'd (which we're tracking on the client roadmap), I believe setting REACT_NATIVE_PACKAGER_HOSTNAME will work for all of the issues raised in this thread, so I'm going to give this a close. Thanks!

@anp anp closed this as completed Oct 17, 2017
@fraylopez
Copy link

Just in case it may help someone. In Windows 10, after looping through all workarounds on this thread with no luck I've managed to get it working by disabling and re-enabling the wifi connection. Besides from the firewall rules, every other setting is out of the box.
It's worth to say that at some point I reset the network settings as well, which cleans all your wifi passwords among other net stuff, proceed carefully.

@bbeckk
Copy link

bbeckk commented Nov 11, 2017

I disabled all the virtualBox adapters and then it worked

@danielkcz
Copy link

danielkcz commented Nov 11, 2017

@bbeckk You are most likely having same issue as me and instead of disabling you can change network adapter priorities ... #270 (comment)

@gbarkhatov
Copy link

It was an issue for me. Having latest versions/updates of everything. Win10, vmware, vbox, create-react-native-app.

Tried disabling and enabling the firewall.

Though it worked from Expo XDE, I just felt like it should work on CLI.

So the issue was (as described earlier by @ahmetkakici) that yarn start was using vmware network adapter.

I went to the settings of my wi-fi adapter and changed metrics on TCPIP4 to 2
https://www.ghacks.net/2016/12/02/change-network-adapter-priorities-in-windows-10/

Now CRNA with yarn start points to the proper IP and everything is working from CLI

@nickcarenza
Copy link

For me this was caused by the port range not being accessible.

To solve, I made a .exprc file like this:

{
	"manifestPort": 8000
}

It seems to be an undocumented config file.

@evanslight
Copy link

I solved this issue through updating my iPhone expo app. It worked smoothly.

@joshuachinemezu
Copy link

Stopped my xampp server and it worked like magic

@gusleo
Copy link

gusleo commented Mar 20, 2018

remove security apps on phone working for me

@aliraza4167
Copy link

Yes the problem was that I had VirtualBox installed and it had its own virtual network adapter. Disabled it and ran "npm run android" and it worked.

@ZulqarnainSyed
Copy link

@FredyC Thanks for your insightful answer. I had a similar problem as there was a virtual connection of VmWare running. Thanks

@hulk-pham
Copy link

hulk-pham commented Jun 24, 2018

In my case, I try
set REACT_NATIVE_PACKAGER_HOSTNAME='localhost'
and it worked

@anp
Copy link
Contributor

anp commented Jun 27, 2018

Hey everyone! This particular issue has been resolved for a while now. If you're still having issues with a similar message and have tried the solutions in this thread, please open a new issue. Thanks!

@expo expo locked as resolved and limited conversation to collaborators Jun 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests