2

我正在执行典型的 HttpUrlConnection 下载以将数据提取到我的应用程序中,但我在某些网络上发现了问题。

这些网络正在为设备分配 ipv6 地址,即使这些网络无法使用 ipv6 正常工作。当然,Android 从 ipv6 故障转移到 ipv4。

在 Jellybean (4.2.2) 中,故障转移需要将近一分钟,这对于移动应用程序来说太长了。我们没有直接控制这些网络。

如果我可以强制 HttpUrlConnection 只使用 ipv4 一切都会好起来的,但我发现没有办法做到这一点。还有其他人吗?

4

1 回答 1

0

Please don't force the application to use IPv4. We are deploying networks that have IPv6-only connectivity (with NAT64/DNS64) and IPv4-only applications will break on such networks. The world is running out of unused IPv4 addresses, and parts of the world (Asia, Europe, Middle East) are already out.

To solve this please look at RFC 6555: Happy Eyeballs. It describes an algorithm that will try IPv6 first but falls back to IPv4 so quickly that the user will hardly notice it (or usually won't notice it at all).

Unfortunately I don't know of a good Java implementation you could use on Android, but I hope others will be able to point you in the right direction. (or you can be the first to write an open source implementation and gain fortune and fame that way (well, fame at least ;))

于 2013-06-25T20:11:53.373 回答