expo / create-react-native-app

Create React Native apps that run on iOS, Android, and web
BSD 3-Clause "New" or "Revised" License
13.26k stars 1.35k forks source link

Network Response Time Out Error #144

Closed aayanqazi closed 7 years ago

aayanqazi commented 7 years ago

Uncaught Error: Java.net,sockettimeoutException: failed to connect to after 10000ms in android after scan QR code

anp commented 7 years ago

Hi! Without the information from the new issue template it's very difficult to help you debug this. In general, you want to make sure that you can reach the development server from your phone. If you take the URL that CRNA prints at startup, and replace exp:// with http://, you should be able to reach that in your phone's browser and see some JSON. If you can see that JSON, but scanning the QR code doesn't work, please open a new issue and complete all of the required sections of the new issue template.

yash2code commented 7 years ago

same issue whatsapp image 2017-04-24 at 13 14 44

aayanqazi commented 7 years ago

@yash2code first check your ip address of your pc .... write ipconfig on cmd ... and then write set REACT_NATIVE_PACKAGER_HOSTNAME='my-custom-ip-address-or-hostname' then start your project again ...

yash2code commented 7 years ago

@aayanqazi

Ethernet adapter VirtualBox Host-Only Network #2: IPv4 Address. . . . . . . . . . . : 192.168.56.1

Now, what to write in place of 'my-custom-ip-address-or-hostname'

aayanqazi commented 7 years ago

@yash2code Your ipv4 address that found in your ipconfig

yash2code commented 7 years ago

@aayanqazi tried that but didnt worked :(

yash2code commented 7 years ago

@dikaiosune please re open this issue

steadycoding commented 7 years ago

Review this https://github.com/react-community/create-react-native-app/blob/master/react-native-scripts/template/README.md#networking @yash2code

aayanqazi commented 7 years ago

@yash2code can u send screenshot of ipconfig command ?

yash2code commented 7 years ago

@steadycoding url timeout in phone's chrome browser but works in desktop chrome browser. Using hotspot as said.

yash2code commented 7 years ago

@aayanqazi my screenshots ofipconfig

capture capture1

aayanqazi commented 7 years ago

Use Wireless LAN Adapter WI-FI Ipv4 Address 192.168.43.244 @yash2code

yash2code commented 7 years ago

@aayanqazi when I goto exp://192.168.43.244 , it starts fetching js bindle but app doesnt opens and restarts my phone giving error this.stream.clearLine() is not a function , Also , on scanning qr code gives same error: Network response time out error

yash2code commented 7 years ago

@dikaiosune I think issue needs to re open .

Jitender-Rathore commented 7 years ago

i am getting the same issue as @yash2code Have done all the steps which you mentioned but still the problem persists. My PC and phone are both connected to wifi. In browser , if i hit the ip address i am getting the json but in phone its giving timeout error. Here is the screenshot of the ipconfig ipconfig

yash2code commented 7 years ago

@Jitender-Rathore send the full screenshot of ipconfig

Jitender-Rathore commented 7 years ago

the sccreenshot which i upload is a full one . I also tried with hotspot .This time i was getting the json when i enter the ip address in mobile browser and desktop but expo was showing the same error

yash2code commented 7 years ago

from my screenshot ........i used this 192.168.43.244 and it worked

phamios commented 7 years ago

how to fix ? I got the same problem

yash2code commented 7 years ago

@phamios show the output of ipconfig

CyrisXD commented 7 years ago

This issue is caused by having virtual network devices, usually installed by virtual machines. React Native chooses the first available network IP which may not be the correct one.

To fix this issue you have to find your local IP address, by entering the Command Prompt and typing: ipconfig or ipconfig /all

If you are on WiFi, look for the WiFi section, and note down your IPv4 Address If you are on Ethernet, look for the Ethernet Adapter section, and note down your IPv4 Address

For Example:

untitled

Once you have your local IP address, navigate to your project folder inside Command Prompt. Inside your project folder run the command.

set REACT_NATIVE_PACKAGER_HOSTNAME=my-custom-ip-address

Replace my-custom-ip-address with your IPv4 Address you noted down earlier.

For example:

cmd_2017-06-14_22-42-00

Then run npm start Scan your QRCode through the Expo app and it should be working.

mkmpvtltd1 commented 7 years ago

https://stackoverflow.com/a/44600431/1756068

bastien-germain commented 7 years ago

Hello,

I have the same issue.

I try this : set REACT_NATIVE_PACKAGER_HOSTNAME=my-custom-ip-address And also the solution from Stack Overflow (open the port 19000 from the machine) It still doesn't work.

I can't access the URL from my phone browser either.

Thanks for your help

lcruz4 commented 7 years ago

I am using git bash and had to use export REACT_NATIVE_PACKAGER_HOSTNAME='192.168.1.123' instead of set REACT_NATIVE_PACKAGER_HOSTNAME still having issues but got past the wrong ip issue.

FYI when you run npm start it tells you in the output the IP it's using. If that IP is not the IP you want then the REACT_NATIVE_PACKAGER_HOSTNAME environment variable is not set properly

hrastnik commented 7 years ago

I've had the same issue. The problem is that the command yarn start or npm start finds the first enabled network adapter it finds which just happens to be the adapter for VirtualBox on my (and many other machines). The solution is to either:

The problem is that Expo finds the first Network adapter, and not the active network adapter that provides the internet connection.

untitled

reza7rm commented 7 years ago

I tested all solutions but Expo still encounters timeout error, it's really on the nerve! deploying using react-native cli was much much better and easier, now I donno why even cli has some issues with watchman and changing the files doesn't reflect on device.

Windows 10 react native 0.47

aliirezaaa commented 7 years ago

i used below command and scan QR with expo app and its work !! npm start but when i use open on android , still has time out error .

mikealche commented 7 years ago

@CyrisXD answer did it for me!! check it out!

I went around disabling virtualhoust, firewalls, etc... but what really happened is that It was exporting the wrong ip adress.

Remember that if you are on windows you need to do "export REACT_NATIVE_PACKAGER_HOSTNAME=my-custom-ip-address" instead of "set REACT_NATIVE_PACKAGER_HOSTNAME=my-custom-ip-address"

cristhian-net commented 7 years ago

This worked for me: I've downloaded adb from android tools then adb reverse tcp:19000 tcp:19000, and I didn't put IPv4 address as recommended... my localhost is 127.0.0.1, so manually entering exp://127.0.0.1:19000 in Expo App worked for me. I don't know why is this, just trial and error

anass05 commented 7 years ago

for anyone who's still facing this problem on windows 1) make sure your phone is connected to the same network as you computer 2) make sure that windows firewall isn't blocking that port, if so make an exception for that port (1900 in my case)

MichaelJob commented 7 years ago

My solution I found while struggeling with the same problem on another machine (osx sierra), while it was working on my first one (osx sierra) - McAfee was blocking it (which was only installed on the second one); disabled it's Firewall and voilà, it works (ios/android)

sustained commented 7 years ago

I'm having the same issue although my setup is really weird and maybe it's just not possible to get this working.

I have a USB broadband dongle and my internet is via a mobile network (4G) plus I'm on Linux (Fedora) and well these devices are not known to work amazingly on Linux to begin with. I reckon that the ISP may well be blocking ports, though, or otherwise interfering with traffic in some way, or something like that (UK mobile networks are notorious for this).

I've tried adding the port to the firewall and so on and so forth (read through the entire thread) but to no avail. Can anyone try to help me?

cristhian-net commented 7 years ago

@sustained Have you tried the solution I posted before? Your phone doesn't need to be on the same network, as it will be connected via USB port (You have to enable USB Debugging on your phone, this is for Android devices). You will need to download adb from Android SDK Platform Tools

sustained commented 7 years ago

I'm actually happy to report that I got it working by opening ports 19000, 19001 and 19002!

lfaz commented 7 years ago

@hrastnik had it right, works on my windows machine by disabling all other network adapters, as mentioned by hrastnik, expo seems not quite smart when detecting the correct network adapter, not looking for the active one, but instead the first one... So disable all other network adapters :)

svekl commented 7 years ago

If you have several network connections, but can't disable any of them, here is nice solution how to do it on Windows machine <spoiler>You need to set up metrics for them</spoiler> https://stackoverflow.com/a/45179856/2089991

czytelny commented 7 years ago

Hi, I just want to share with you what cause 'Network Response Time Out Error' error in my case. It wasn't firewall, it wasn't virtual box. My computer with windows which I use to host React Native App was connected to my home network but was unreachable from any other computer (or phone) because it was setup as a "Guest or public" network profile. When I changed this network profile to "Private" it started working :) cheers

vishalgadhiya91 commented 6 years ago

Can you try after "Windows firewall " Off ?

ziggyjosh16 commented 6 years ago

My issue probably stems from the fact that the app is running from a Linux Virtual machine. How can I get my device and the virtual machine to be on the same network?

harisvsulaiman commented 6 years ago

I have this issue in a production application where expo doesnt connect to ip.


arrow_drop_down
Exception java.lang.RuntimeException: java.net.SocketTimeoutException: failed to connect to [REDACTED_DOMAIN_NAME]/[REDACTED_IP_ADDRESS] (port 443) after 10000ms
host.exp.exponent.kernel.ExpoViewKernel.handleError (ExpoViewKernel.java:76)
host.exp.expoview.ExponentActivity$3$1.onError (ExponentActivity.java:195)
host.exp.expoview.Exponent$2.onFailure (Exponent.java:439)
host.exp.exponent.network.ExponentHttpClient$2$1.onFailure (ExponentHttpClient.java:95)
expolib_v1.okhttp3.RealCall$AsyncCall.execute (RealCall.java:142)
expolib_v1.okhttp3.internal.NamedRunnable.run (NamedRunnable.java:32)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1112)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:587)
java.lang.Thread.run (Thread.java:818)
arrow_drop_down
Caused by java.net.SocketTimeoutException: failed to connect to [REDACTED_DOMAIN_NAME]/[REDACTED_IP_ADDRESS] (port 443) after 10000ms
libcore.io.IoBridge.connectErrno (IoBridge.java:169)
libcore.io.IoBridge.connect (IoBridge.java:122)
java.net.PlainSocketImpl.connect (PlainSocketImpl.java:183)
java.net.PlainSocketImpl.connect (PlainSocketImpl.java:456)
java.net.Socket.connect (Socket.java:882)
expolib_v1.okhttp3.internal.platform.AndroidPlatform.connectSocket (AndroidPlatform.java:63)
expolib_v1.okhttp3.internal.connection.RealConnection.connectSocket (RealConnection.java:220)
expolib_v1.okhttp3.internal.connection.RealConnection.connect (RealConnection.java:146)
expolib_v1.okhttp3.internal.connection.StreamAllocation.findConnection (StreamAllocation.java:186)
expolib_v1.okhttp3.internal.connection.StreamAllocation.findHealthyConnection (StreamAllocation.java:121)
expolib_v1.okhttp3.internal.connection.StreamAllocation.newStream (StreamAllocation.java:100)
expolib_v1.okhttp3.internal.connection.ConnectInterceptor.intercept (ConnectInterceptor.java:42)
expolib_v1.okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:92)
expolib_v1.okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:67)
expolib_v1.okhttp3.internal.cache.CacheInterceptor.intercept (CacheInterceptor.java:93)
expolib_v1.okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:92)
expolib_v1.okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:67)
expolib_v1.okhttp3.internal.http.BridgeInterceptor.intercept (BridgeInterceptor.java:93)
expolib_v1.okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:92)
expolib_v1.okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept (RetryAndFollowUpInterceptor.java:120)
expolib_v1.okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:92)
expolib_v1.okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:67)
host.exp.exponent.network.ExponentNetwork$3.intercept (ExponentNetwork.java:140)
expolib_v1.okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:92)
expolib_v1.okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:67)
expolib_v1.okhttp3.RealCall.getResponseWithInterceptorChain (RealCall.java:179)
expolib_v1.okhttp3.RealCall$AsyncCall.execute (RealCall.java:129)
expolib_v1.okhttp3.internal.NamedRunnable.run (NamedRunnable.java:32)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1112)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:587)
java.lang.Thread.run (Thread.java:818)
sumethy commented 6 years ago

Hi,

I had to both disable all other network adaptors AND change the network setting to "private" to get Expo working in Windows. Thank @hrastnik and @czytelny .

davidRoussov commented 6 years ago

I can confirm disabling the Windows Firewall fixed this issue for me.

AurelGit commented 6 years ago

Same problems, and working without firewall. What i did to fix it, on Windows 10.

  1. The famous "set REACT_NATIVE_PACKAGER_HOSTNAME=my-custom-ip-address"
  2. Authorize ports 19000, 19001 and 19002 -- https://stackoverflow.com/a/44600431/1443984
  3. change the network to "private" (thanks @sumethy) -- On Windows 10, you can left click on the "wi-fi" icon in system tray > "Properties" > switch to "Private" in the "Network Profile" section.

It fixed this issue for me.

CagatayKolus commented 6 years ago

Hi,

I got same problem and i fixed with turning off all Ethernet Adapters except Wi-Fi Ethernet adapter. If you using any adapter such as VirtualBox Adapter, Hamachi Adapter etc. turn off all of them.

When u type "npm start" it will give you new IP adress and verify QR code again and it will works!

cosmar26 commented 6 years ago

Ubuntu 16.04 same problem, it's fixed just by disabling firewall sudo ufw disable

doble-d commented 6 years ago

Same problem, in my host pc if I use the IP I get: This site can’t be reached If I use http://localhost:/19000 it shows a json file.

In my phone nothing works, oh man.

iamsayantan commented 6 years ago

I had the same issue on Windows 10. Disabling virtual network adapters and allowing the port through windows firewall fixed it. Thanks to @CyrisXD and @anass05 .

ToJen commented 6 years ago

@mkmpvtltd1 thanks that worked for me!

jalal246 commented 6 years ago

@CristhianUNSa Amazing.. after a couple of days of searching your solution works perfectly THANK YOU SO MUCH!

n3gotium commented 6 years ago

If you have tried all of the above solutions and you still can't connect to your computer from your mobile device and your both devices get connected throw a router, then it might be that you have the wireless isolation feature turned on somewhere in your router's configuration.

When this feature is turned on, it disallows clients connected to the Wi-Fi network to interact with devices connected to the wired network, nor can they communicate with each other. They can only access the Internet.

You can read more about this feature here: https://www.howtogeek.com/179089/lock-down-your-wi-fi-network-with-your-routers-wireless-isolation-option/