无法解析主机:没有与主机名关联的地址

发布于 2025-01-13 08:54:32 字数 379 浏览 3 评论 0原文

在我的 Android 应用程序中,我使用通过 cloudflare 网络(带有主动代理)交付的 Rest API。很多时候,第一次连接 okhttp API 时会收到以下错误:

Non-fatal Exception: java.net.UnknownHostException
Unable to resolve host "mydomain.com": No address associated with hostname

用户重试一次或多次后,后续连接会成功。如果 API 请求出现一些停机时间,则该错误可能会再次发生。

我不明白是什么原因导致了这个问题。是否可以依赖cloudflare或者okhttp方面是否有办法解决。

你有什么想法吗?

In my Android application I use my Rest API, delivered via the cloudflare network (with active proxy). Very often the first connection to the okhttp API receives the following error:

Non-fatal Exception: java.net.UnknownHostException
Unable to resolve host "mydomain.com": No address associated with hostname

After the user retries one or more times, subsequent connections are successful. If there is some downtime with API requests, the error is likely to occur again.

I cannot understand what causes this problem. If it can depend on cloudflare or if there is a way to solve on the okhttp side.

do you have any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

骷髅 2025-01-20 08:54:32

或者您的设备上没有互联网

,或者您忘记在manifest.xml中添加

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

权限

@see 此线程

Or you have no internet on the device

or you forgot to add

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

permission in manifest.xml

@see this thread

沧笙踏歌 2025-01-20 08:54:32

我的一个加密钱包也遇到了同样的问题,只是发现我的应用程序需要更新,一旦我更新了应用程序,从那时起一切就都很顺利了。当我第一次去 Play 商店查看是否有任何更新时,没有任何更新,但当我在 Play 商店中专门搜索我的钱包应用程序时,需要更新。因此,请确保您在 Play 商店中搜索出现问题的特定应用程序。

I had the same problem with one of my crypto wallets only to discover my app needed to be updated and once I updated the app everything was smooth from that point on. When I first went to the Play Store to see if I had any updates due, there were none but when I searched specifically for my wallet app in the Play store an update was needed. So make sure you search for the specific app that is giving you the problem in the Play store.

泛滥成性 2025-01-20 08:54:32

我也有同样的问题,但重新启动 android studio 后它解决了我的问题。

I have also the same issue but after restarting android studio it solved my problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文