如何解决SocketException:主机查找失败:'www.xyz.com'(操作系统错误:没有与主机名关联的地址,errno = 7) [英] How to solve SocketException: Failed host lookup: 'www.xyz.com' (OS Error: No address associated with hostname, errno = 7)

查看:2234
本文介绍了如何解决SocketException:主机查找失败:'www.xyz.com'(操作系统错误:没有与主机名关联的地址,errno = 7)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我尝试在大约20秒后进行http呼叫,我都会在控制台中遇到以下错误:

Whenever I try to do an http call after about 20 seconds I get in the console the following error:

E/flutter ( 8274): [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
E/flutter ( 8274): SocketException: Failed host lookup: 'flutter-project-xxxxx.firebaseio.com' (OS Error: No address associated with hostname, errno = 7)

我通过应用程序http包调用的每种方法和每条路线都会发生此错误.

This error happens for every method and every route I call through the app http package.

我正在使用Windows Studio中的AVD虚拟设备在Windows上开发Flutter应用.

I'm developing a flutter app on Windows, using an AVD virtual device from Android Studio.

版本:

  http: ^0.12.0+1
  flutter: 1.0

情况:

  1. 在家中或通过手机进行网络共享: 连接在虚拟设备的每个部分上都能正常工作

  1. From home or though tethering from my phone: connectivity works fine on every part of the virtual device

从我的工作网络(在防火墙之后):

From my work network (behind the firewall):

只有使用Android Web View,我才能毫无问题地浏览互联网(我甚至可以调用相同的url,我在代码中使用它就可以了). 在测试我的应用程序时,在虚拟设备中使用任何其他应用程序(Chrome,Google Play,ecc ...),特别是"SocketException"时,出现连接错误.

Only with Android Web View, I can browse the internet without any problem (i can even call the same url, I use in the code and it works). I get a connection error when using any other application (Chrome, Google Play, ecc...) in the virtual device, and specifically the "SocketException", when testing my app.

从该应用发出的呼叫之间有什么区别? 有没有一种方法可以路由我的应用程序调用,就像在网络视图中一样?

What is the difference between the calls coming from that app? Is there a way to route my app calls the same way as the ones in the webview?

谢谢!

推荐答案

添加 Internet权限不仅是一种解决方案.
无论是移动设备还是仿真器
,您还必须确保自己在线

Adding internet permission is not only a solution.
You also have to make sure that you are online whether it is mobile or emulator

  1. 确保您在线,无论它是移动设备还是仿真器.

  1. Make sure you are online whether it is mobile or emulator

确保您已在应用的android/app/src/main/AndroidManifest.xml中授予了Internet权限

Make sure you have given internet permission in your app's android/app/src/main/AndroidManifest.xml

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

这篇关于如何解决SocketException:主机查找失败:'www.xyz.com'(操作系统错误:没有与主机名关联的地址,errno = 7)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆