- [Upstream Long-Thinking Idle Keep-Alive & Connection Stability Hardening] Inject Underlying Hyper HTTP/2 PING Frames and Unify base_client_builder to Prevent L7 Proxy Idle Truncation & Stream Drops (PR #3571, Fixes #2195, Fixes #1796, Fixes #2013, Thanks to @EricZhou05):
- Underlying Hyper HTTP/2 PING Keep-Alive Frame Injection: During deep thinking, large code block generation, or complex planning, upstream models can remain silent for 10~15 seconds before the first data chunk. Local proxy environments (Clash, soft routers, corporate gateways) enforce Layer 7 (L7) idle read timeouts, killing connections with
RST_STREAManderror reading a body from connection. By penetratingrquest's underlyinghyperprotocol stack withkeep_alive_interval(3s),keep_alive_timeout(10s), andkeep_alive_while_idle(true), periodic HTTP/2 PING frames keep the stream active and continuously reset intermediate L7 proxy idle timers, permanently eradicating stream drops and upstream token waste. - Unified base_client_builder Eradicates Configuration Drift: Refactored
UpstreamClientconstruction logic to a centralizedbase_client_builder, ensuring both default upstream clients and per-account ProxyPool clients share identical connection pooling, HTTP/2 PING keep-alive, and 3-second TCP keepalive parameters, eliminating configuration drift and maintenance regressions. - Enhanced TCP Keepalive Sensitivity: Adjusted TCP keepalive probe intervals from 60 seconds to 3 seconds, significantly boosting responsiveness and connection health recovery in complex network topologies.
- Underlying Hyper HTTP/2 PING Keep-Alive Frame Injection: During deep thinking, large code block generation, or complex planning, upstream models can remain silent for 10~15 seconds before the first data chunk. Local proxy environments (Clash, soft routers, corporate gateways) enforce Layer 7 (L7) idle read timeouts, killing connections with
- [上游长思考静默期保活与连接稳定性根治] 穿透底层 hyper 注入 HTTP/2 PING 帧,统一 base_client_builder 杜绝代理 L7 空闲截断与流式腰斩 (PR #3571, Fixes #2195, Fixes #1796, Fixes #2013, Thanks to @EricZhou05):
- 底层 Hyper HTTP/2 PING 保活帧穿透注入: 针对深度思考、长代码生成、大型脚本编写或制定复杂工作计划时上游服务长达 10~15 秒数据生成静默期导致的流式中断,直接穿透
rquest底层hyper协议栈配置keep_alive_interval(Duration::from_secs(3))、keep_alive_timeout(Duration::from_secs(10))与keep_alive_while_idle(true)。通过向连接周期性注入标准 HTTP/2 PING 帧并由服务端 ACK,持续重置本地代理(如 Clash、软路由、网络代理)的应用层(L7)空闲读超时计时器,彻底根除error reading a body from connection、RST_STREAM报错及 Token 浪费。 - 统一 base_client_builder 消除配置漂移: 重构
UpstreamClient基础构建逻辑为base_client_builder,使默认客户端与代理池(ProxyPool)专属客户端 100% 共享连接池复用、HTTP/2 PING 保活机制及 3 秒 TCP Keepalive 探测参数,杜绝因代码重复引起的配置遗漏与行为分歧。 - TCP Keepalive 灵敏度提升: 将底层 TCP Keepalive 探测周期从 60 秒缩短至 3 秒,显著提升长连接在弱网与复杂拓扑下的故障感知与自愈效率。
- 底层 Hyper HTTP/2 PING 保活帧穿透注入: 针对深度思考、长代码生成、大型脚本编写或制定复杂工作计划时上游服务长达 10~15 秒数据生成静默期导致的流式中断,直接穿透
What's Changed
- fix(proxy): prevent stream drop during long generation via HTTP/2 PING (Fixes #2195, #1796, #2013) by @EricZhou05 in #3571
Full Changelog: v4.8.8...v4.8.9