Duplicate POST Writes Occur When HttpClient Retries After Timeout in Xamarin.Android
0 reputation · 08 Feb 2021, 15:18 UTC
Problem Statement
The goal is to configure Xamarin’s HttpClient so that a transient network timeout does not cause the same non‑idempotent POST to be sent twice, which would create duplicate records on the server. Xamarin’s HttpClientHandler provides no built‑in retry mechanism, so any custom retry logic must be added by the developer, but the framework does not supply a standard way to generate a unique request‑ID header that could be used for server‑side deduplication.
Constraints include the inability to rely on server‑side idempotency for POST operations, the need to preserve request semantics across process restarts, and the risk that a naïve retry implementation will re‑issue the exact same payload.
- What approach can be used to generate a stable, unique request‑ID in Xamarin.Android that survives app restarts?
- How should custom retry logic be written to avoid retrying POST requests unless the server explicitly indicates the operation is safe to repeat?
- Is it sufficient to depend on a server‑provided request‑ID header for deduplication, or should a client‑side request cache be maintained?