My app does not connect to internet anymore, but only when in wifi


#1

Hi,

I have upgraded to cordova 5.2.0 and I’m also using crosswalk v14+ with the plugin.
I’m running my app on my Android phone and on my Android tablet and before the upgrade everything was working (I had to upgrade because I had some issues that have been resolved in new versions) now my app can connect to internet only in 2g/3g, when in wifi the connection does not work.

I tried to install cordova-plugin-whitelist and to check that I have all permissions in my config.xml and AndroidManifest.xml:
in AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

in config.xml:

<access origin="*" />
<plugin name="cordova-plugin-whitelist" version="1" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />

but it does not work.
Does anybody know why such a strange behavior? In 2g/3g everything works, in wifi nothing works.

I tried to debug my app and I ran:

  • window.navigator.onLine gives me true,
  • navigator.connection.type gives me wifi.

Also when excecuting some AJAX calls I received: net::ERR_NAME_NOT_RESOLVED from jquery-2.1.4.

Thanks


#2

Are you using jQuery for AJAX communication?


#3

yes.
Something like:

       $.ajax({
           type: 'GET',
           url: URL,
           dataType: "json",
           success: function(result) {
             //....
           }
       .fail (function(jqXHR, textStatus, errorThrown) {
            //....
        });

       });

#4

May I ask, and I’m not accusing you of anything, why are you using jQuery and $.ajax method?

AngularJS has everything you need plus Ionic don’t play well with some jQuery versions.


#5

because I’m still migrating my code from other lib to ionic, so I still need to use those.