Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic 2 - Error : net::ERR_CONNECTION_TIMED_OUT when run on android device

(Sorry for my bad English)

I have built an application with Ionic 2 for Android. In this application I need to get information from an API and it's works perfectly when I run do it in the browser (ionic serve).

The problem is when I run on my device (Android 6.0.1) I get this issue :

net::ERR_CONNECTION_TIMED_OUT

Then I searched how to resolve this and I tried many things.

I have the cordova-plugin-whitelist and my config.xml looks like :

<content src="index.html" />
<allow-navigation href="*" />
<allow-intent href="*" />
<access origin="*" subdomains="true" />

and I put this in my index.html :

<meta http-equiv="Content-Security-Policy" content="default-src *; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'; img-src * data: 'unsafe-inline'; connect-src * 'unsafe-inline'; frame-src *; media-src *;">

I have read many documentation concerning this issue but I didn't find anything really helpful.

Can someone help me please ?

Thanks

like image 589
Chabrioche Avatar asked Dec 01 '22 11:12

Chabrioche


1 Answers

All I have to do is to make sure ionic cordova run android -l -c -s works on my android phone.

  1. Both my laptop and phone is on the same network.
  2. I can access to the livereload server (on my laptop). E.g. http://192.168.1.5:8100 can be access on my phone chrome browser.

If step 2 cannot be done. Do the following on Windows 10 to enable the firewall setting on my laptop for Node.js Click here for picture of Enable firewall configuration

like image 70
Kevin Ng Avatar answered Dec 04 '22 13:12

Kevin Ng