Search code examples
androidcordovaionic2httprequest

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


Solution

  • An obvious connectivity issue as stated in the error.

    Ensure that the resource you are trying to access via the app is directly accessible in mobile browser first. If you ensure its accessibility in device browser, then the app connectivity issue will be resolved for sure. Cheers