2

I need assistance with my Ionic app. It works on Android device using "@ionic-native/http": "^5.30.0" The problem is very strange..

Let's say we have a simple username/password login form.

  1. Initially we are using 4G to login and the login is successful (The problem is not only with the login)
  2. We log out of the app and we see the same screen - the login form..
  3. On the device itself we turn on the WiFi and connect to any network (with or without internet)
  4. If we try to login with the connected network (if there's internet, the login will be successful)
  5. We will not use the WiFi and we want to revert using 4G again as the first time.
  6. We disconnect manually the WiFi
  7. On login we will receive error: {"status":-3,"error":"Host could not be resolved: java.net.UnknownHostException: Unable to resolve host

Surely there is network connection, as I can minimize the application and browse the web, also connect to the server and make HTTP call to it.

This used to work before a couple of months when I was playing around with it..

I have the server domain in the NetworkSecurity.config
I have these permissions in my app.component.ts

  this.androidPermissions.requestPermissions([
    this.androidPermissions.PERMISSION.CAMERA, 
    this.androidPermissions.PERMISSION.CHANGE_NETWORK_STATE,
    this.androidPermissions.PERMISSION.CHANGE_WIFI_STATE,
    this.androidPermissions.PERMISSION.DUMP,
    this.androidPermissions.PERMISSION.INTERNET,
    this.androidPermissions.PERMISSION.MANAGE_EXTERNAL_STORAGE,
    this.androidPermissions.PERMISSION.WRITE_EXTERNAL_STORAGE,
    this.androidPermissions.PERMISSION.ACCESS_WIFI_STATE,
    this.androidPermissions.PERMISSION.ACCESS_NETWORK_STATE,
    this.androidPermissions.PERMISSION.ACCESS_BACKGROUND_LOCATION
  ]);

I have also enabled fast network switch from dev options.

I've read s lot in the web related to this problem but can't find a solution.

I've tried updating all packages, reinitializing the platform and removing the node modules The behavior is consistent and can be reproduced every time.

A.Sideris
  • 530
  • 3
  • 18

1 Answers1

2

After a lot of digging, I found out, that the problem was in a library I was using "WifiWizard2"and a parameter called "bindAll".......

There's a PR.. https://github.com/tripflex/WifiWizard2/pull/102

A.Sideris
  • 530
  • 3
  • 18
  • 1
    Thankyou - I know you answered this a long time ago but this has solved my problem. After your answer I narrowed it down to bindProcessToNetwork which according to the docs any sockets bound this way on a network will fail to work after the network disconnects. – edp Apr 15 '21 at 18:14