XHTTP XMUX: Abandon client
if client.Do(req)
failed
#4253
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
最近对 XHTTP 进行了“换网测试”,发现 H2 仍存在切换网络后“断流”的问题(只能等保活检查),而 H3 有一定概率不会断,应该是连接迁移了。尚未研究“多少秒不活跃触发保活检查”的对象是否包含“未响应”,时间是否就是
hKeepAlivePeriod
。所以这个 PR 继承了 #4163 未竟的事业,重新引入了 51769fd :任一 HTTP 请求返回 err 就不再分配新请求。
(context.WithoutCancel(ctx) 确保了不是客户端引发的 err,此前 stream-up 上行没加它,再加上服务端迟迟未响应,疯狂报错)
这个 PR 还补上了一些
io.Copy(io.Discard, resp.Body)
,以防 Golang 错误地认为底层连接不应被继续复用,我不确定。由于 stream-up 上行旧服务端迟迟未响应、导致最后返回了 err,这个 PR 类似 REALITY 会把客户端版本发给服务端,所以新服务端会向新客户端及时响应 200,这解决了 stream-up 上行状态码为 400/499、被 CDN 掐断 #4113 (comment) 的问题。还有 836e84b 我不确定要不要引入,似乎 Go 已经没这问题了?#4306
0xDc3Fe44F0f25D13CACb1C4896CD0D321df3146Ee