Mobile Development 6 min read

Happy Eyeballs Implementation in Baidu App: IPv4 to IPv6 Transition Best Practices

The article explains how Baidu App adopts the Happy Eyeballs protocol—using both RFC 6555 and RFC 8305—to seamlessly transition from IPv4 to IPv6 by concurrently querying DNS, alternating address order, and employing short‑delay fallbacks in its ijkplayer, Cronet, OkHttp, and WKWebView components.

Baidu App Technology
Baidu App Technology
Baidu App Technology
Happy Eyeballs Implementation in Baidu App: IPv4 to IPv6 Transition Best Practices

This article discusses the Happy Eyeballs protocol as a standard solution for transitioning from IPv4 to IPv6, addressing connectivity and reliability issues during the early IPv6 deployment phase.

Happy Eyeballs solves the core problem of selecting between IPv4 and IPv6 addresses in complex environments. It provides a comprehensive solution covering DNS query handling, address sorting, and connection attempts. Two versions exist: RFC6555 (v1, proposed by Cisco) and RFC8305 (v2, proposed by Apple).

Baidu App's Happy Eyeballs implementation covers its core business and underlying network libraries including ijkplayer (RFC8305), OkHttp (RFC6555), and Cronet (RFC6555).

ijkplayer Implementation: Uses localDNS to query both v4 and v6 addresses simultaneously (A record for IPv4, Type 1; AAAA record for IPv6, Type 28). Addresses are sorted in an alternating pattern with IPv6 first, followed by IPv4. For connection attempts, it immediately tries IPv6 with a timeout that is the minimum of the user-defined value and 200ms (RFC8305 recommendation). If IPv6 fails within this window, it proceeds to IPv4, and continues alternating until a successful connection is established.

Cronet Implementation: Uses HTTPDNS which returns both IPv4 and IPv6 addresses simultaneously. Happy Eyeballs is enabled when the first result is IPv6 and both IPv4 and IPv6 addresses are present. It immediately attempts IPv6 connection while starting a delayed IPv4 connection task (300ms, per RFC6555 recommendation). If IPv6 succeeds within 300ms, the delayed task is canceled. Otherwise, it enters competition mode where both IPv4 and IPv6 connections compete, with IPv6 taking precedence if it succeeds during the competition window.

OkHttp Implementation: Baidu App implemented OkHttp's Happy Eyeballs following RFC6555, with details similar to Cronet. The implementation integrates with OkHttp's request concurrency control module (max 64 threads, max 5 concurrent connections per domain) and core interceptor modules.

WKWebView: In scenarios where WKWebView is not managed by Cronet, it relies on Apple's native Happy Eyeballs implementation.

IPv6Mobile DevelopmentCronetnetwork protocolijkplayerOkHttpBaidu AppHappy EyeballsRFC6555RFC8305
Baidu App Technology
Written by

Baidu App Technology

Official Baidu App Tech Account

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.