Skip to content

fix: 修正现代.NET KeepAlive毫秒到秒换算 - #76

Merged
CSJ608 merged 1 commit into
mainfrom
codex/fix-62-keepalive-units
Sep 8, 2026
Merged

CSJ608 merged 1 commit into
mainfrom
codex/fix-62-keepalive-units

Conversation

@CSJ608

@CSJ608 CSJ608 commented Sep 8, 2026

Copy link
Copy Markdown
Owner

开启 TCP KeepAlive 后,现代 .NET 曾将默认 30000/5000 毫秒直接设置为 30000/5000 秒。本修复按维护者决议将正毫秒向上取整为秒(默认30/5秒,1500ms→2s,1ms→1s),采用先减后除避免 int.MaxValue 溢出。保留正数校验、默认关闭和 netstandard2.0 IOControl 毫秒路径;更新选项说明、双语 README 和 Unreleased。

验证:

  • 真实 TCP 连接通过 GetSocketOption 读回操作系统配置:默认、1500/2500ms、1/999ms、整秒及默认关闭;另测最大 int 换算。net48 读回默认30/5秒验证 IOControl 兼容。
  • 修改前 Windows net8:4项红灯(默认静默读回30000、1500读回1500、999间隔读回999);修改后全部转绿。
  • dotnet build StreamFrame.slnx -c Release:0警告/0错误。
  • dotnet test StreamFrame.slnx -c Release --no-build:net8 129/129、net10 129/129、net48 121/121通过。
  • 首次全量及单项复查曾遇到既有 net48 RapidServerInitiatedReconnects_PortStaysAcceptable 状态断言失败;干净main单项通过,最后全量原命令通过。该测试未开启KeepAlive,未更改断言或其实现,保留为时序不稳定观察,不声称修复其根因。
  • Ubuntu net8/net10 与 Windows net48 由本 PR CI 继续核验。

单位依据:SocketOptionName(秒)、SIO_KEEPALIVE_VALS(毫秒)。

Closes #62

@CSJ608
CSJ608 merged commit 84766af into main Sep 8, 2026
5 checks passed
@CSJ608
CSJ608 deleted the codex/fix-62-keepalive-units branch September 8, 2026 08:50
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.

bug: [P1] 修正现代 .NET TCP KeepAlive 配置的毫秒/秒单位错配

1 participant