Diagnosing Intermittent Connection Pool Exhaustion in Xamarin HttpClient
23K reputation · 02 Dec 2022, 14:16 UTC
Problem Description
Xamarin’s HttpClient relies on platform‑specific handlers (OkHttp on Android, CFNetwork on iOS). The default connection pool is opaque; no public API exposes its size or timeout. When many concurrent requests are issued, the pool may silently drop connections after a timeout, leading to intermittent failures.
Unresolved Decision
For projects targeting .NET Standard 2.0 or earlier, HttpClientFactory is unavailable, leaving developers to choose between creating a new HttpClient per request or reusing a single shared instance. The documentation does not specify the exact pool size, timeout thresholds, or how the underlying platform limits (e.g., OkHttp’s 5 max per host) interact with Xamarin’s pool, creating uncertainty around how to avoid exhaustion in high‑traffic scenarios.
What is the default connection pool size for Xamarin’s HttpClient on Android and iOS? How do platform limits affect the pool when many simultaneous requests are made? Does reusing a single HttpClient reliably prevent exhaustion, or are there hidden side effects such as stale DNS or cookie data?