Skip to content

心跳保活示例 + 空闲超时 0 字节完成误判修复 - #30

Merged
CSJ608 merged 1 commit into
mainfrom
feat-heartbeat-sample
Aug 27, 2026
Merged

CSJ608 merged 1 commit into
mainfrom
feat-heartbeat-sample

Conversation

@CSJ608

@CSJ608 CSJ608 commented Aug 27, 2026

Copy link
Copy Markdown
Owner

心跳示例

  • demo 新增场景 4:周期心跳(PING/PONG,周期 = 超时 1/3)+ ReceiveIdleTimeoutMs 的完整范式;断言设计为诚实对照——有心跳时连接稳定(零状态事件),停止心跳后空闲判定触发重连状态翻动(真实猝死时对端不可达、会停留在 Connecting)
  • README(双语)活性探测小节扩充心跳范式代码片段

修复(写示例时挖出的真 bug)

  • 空闲超时 0 字节完成误判:Windows 会把取消中的接收折算成 0 字节完成而非抛取消异常,被当作对端正常关闭(FIN)——现统一按会话故障处理(最小复现 → 诊断日志定位 → 修复)
  • demo 场景 3 竞态:强制重连瞬间旧会话仍为 Connected,WaitForConnectedAsync 走立即完成快速路径,断言撞上对方毫秒级的 Connecting→Connected 过渡——改为轮询双方状态(时间线诊断实锤),10 连跑无抖动

验证

demo 10/10 全过;三框架 55×3 全绿。

@CSJ608
CSJ608 merged commit ab4b513 into main Aug 27, 2026
4 checks passed
@CSJ608
CSJ608 deleted the feat-heartbeat-sample branch August 27, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant