问题描述
我正在构建一个在 Android 9 上运行的应用。
一旦我使用此库 wifi_configuration 从我的应用程序连接到 WIFI 网络,我无法使用 HTTP 库向 http://192.168.80.1:4443 发出成功的 HTTP 请求,但可以毫无问题地向 http://www.google.com 发出请求。我对 http://192.168.80.1:4443 的请求挂起并导致以下错误:SocketException: OS Error: Connection timed out,errno = 110,address = 192.168.80.1,port = 55496 图书馆无法毫无问题地连接到网络。
如果我直接从 Android UI 连接到 WIFI,则向 http://192.168.80.1:4443 发出 HTTP 请求没有问题。因此,当从我的应用程序连接到 WIFI 并调用 http://192.168.80.1:4443 时会出现问题。可能是因为它不是域而是 IP 地址?
是否有任何权限/限制影响向您的应用连接到的网络发出 HTTP 请求?
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;
}