Commit fed8979
committed
fix: disable HTTP/2 to eliminate CONNECT-tunnel churn under concurrency
When the same twikit Client is shared across high-concurrency tasks (or
when many clients share an upstream CONNECT proxy), ``http2=True``
produces two failure modes that surface as ``ConnectError`` /
``[SSL: RECORD_LAYER_FAILURE]`` and 502s in the calling service:
1. httpx opens a new CONNECT tunnel per concurrent task at race time,
then closes it once another task wins the multiplexing race on an
already-open h2 connection. In production, 3proxy logs ~67% of
tunnels with error code 21 (client closed before sending TLS data),
leaving only ~26% of tunnels actually carrying traffic.
2. ALPN-negotiated h2 through CONNECT exposes a Cloudflare bot-detection
RST path mid-handshake that surfaces as ``RECORD_LAYER_FAILURE`` for
~10% of requests originating from datacenter IPs. HTTP/1.1 with
keep-alive avoids the negotiation entirely and Cloudflare lets it
through.
X.com's GraphQL is HTTP/1.1-friendly, and the perf cost of dropping h2
is negligible at this concurrency profile (the keep-alive pool was the
bottleneck, not stream multiplexing). Apply the same change to the guest
client so unauthenticated calls share the same transport behaviour.1 parent 699fb17 commit fed8979
2 files changed
Lines changed: 16 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
115 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
116 | 126 | | |
117 | 127 | | |
118 | 128 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
90 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
| |||
0 commit comments