0

I'm building an app running on Android 9.

Once I connect to a WIFI network from my app using this library wifi_configuration I cannot make a successful HTTP request with the HTTP library to http://192.168.80.1:4443 but to http://www.google.com without a problem. My request to http://192.168.80.1:4443 hangs and results in the following error: SocketException: OS Error: Connection timed out, errno = 110, address = 192.168.80.1, port = 55496 The library can't connect to the networks without any issues.

If I connect to the WIFI directly from the Android UI, I have no problem making the HTTP requests to http://192.168.80.1:4443. So the problem occurs when connecting to the WIFI from my app and calling http://192.168.80.1:4443. Could it maybe be because it is not a domain but an IP address?

Are there any permissions/restrictions affecting making the HTTP request to networks that your app connects you to?

var ssid = 'ssid';
var password = 'password';

WifiConnectionStatus connectionStatus = await WifiConfiguration.connectToWifi(ssid, password, "com.appname");

switch (connectionStatus) {
  case WifiConnectionStatus.connected:
    var response = await http.get('http://192.168.80.1:4443/'); // NOT WORKING, the response hangs when connected to the WIFI from the app.
    var response = await http.get('http://www.google.com'); // WORKING
    break;

  case WifiConnectionStatus.alreadyConnected:
    print("alreadyConnected");
    break;

  case WifiConnectionStatus.notConnected:
    print("notConnected"); 
    break;

  case WifiConnectionStatus.platformNotSupported:
    print("platformNotSupported");
    break;

  case WifiConnectionStatus.profileAlreadyInstalled:
    print("profileAlreadyInstalled");
    break;

  case WifiConnectionStatus.locationNotAllowed:
    print("locationNotAllowed");
    break;
}
Daniel
  • 546
  • 6
  • 17

1 Answers1

0

Will, I don't know about this package but I use this one which works with no problem and does the same things you want like connecting to a wifi network. also, there is a problem that it might help you as there is an update on making an HTTP request and instead you should make HTTPS requests for security reasons, but it can be fixed by this solution

Shalabyer
  • 555
  • 7
  • 23