Connect to a closed loopback port takes 2 seconds per address on Windows; libuv, curl and Chromium avoid it with SIO_TCP_INITIAL_RTO
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- csharp
- 領域
- networking
調査の方向性
Start by reading the Windows socket connection code in System.Net.Sockets and the related tests for loopback connections. Check how the proposed SIO_TCP_INITIAL_RTO ioctl is supported across Windows versions and where failures can be safely ignored. Done means refused loopback connections fail faster while successful connections and non-loopback connections remain unaffected.
索引モデルが issue の本文から書いたものです。
説明
Description
On Windows, connecting to a loopback port where nothing listens takes about 2 seconds before SocketException ConnectionRefused. For localhost it's about 4 seconds, because ::1 and then 127.0.0.1 each wait. On Linux the same call fails in about a millisecond.
Repro with .NET 10.0.14 on Windows 11 26100.
var s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
s.Connect(IPAddress.Loopback, 59321); // ~2,030 ms, then ConnectionRefused
HttpClient.GetAsync("http://localhost:59321/") takes about 4,080 ms. On WSL2 on the same machine, both take 1 to 3 ms.
Configuration
.NET 10.0.14, Windows 11 26100 x64 (Intel Core i9-10900K). Linux numbers are from WSL2 on the same machine with the same .NET.
Regression?
No. #65375 and #31085 reported the localhost part and were closed as OS behavior.
Data
From .NET the same thing works today with socket.IOControl(unchecked((int)0x98000011), new byte[] { 0, 0, 254, 0 }, null) before Connect. With it the refused connect takes 2.6 ms for 127.0.0.1 and 1.1 ms for ::1, and an HttpClient with a ConnectCallback that does this gets http://localhost down from 4,083 ms to 9.5 ms. Connects that succeed are unchanged.
Analysis
The time is Windows retransmitting the SYN after the RST. It can be turned off per socket, and libuv (Node), curl (curl/curl#22494) and Chromium do that for loopback destinations.
TCP_INITIAL_RTO_PARAMETERS p = { TCP_INITIAL_RTO_DEFAULT_RTT, TCP_INITIAL_RTO_NO_SYN_RETRANSMISSIONS };
WSAIoctl(sock, SIO_TCP_INITIAL_RTO, &p, sizeof(p), NULL, 0, &bytes, NULL, NULL);
There's no system-wide way to get this. Set-NetTCPSetting accepts MaxSynRetransmissions from 2 to 8 only.
Would you take a change that sets this ioctl in System.Net.Sockets on Windows when the remote address is loopback, ignoring failures (older Windows)? It only affects loopback, where there's no link to lose a SYN on. It matters for tools and test suites that poll for a local server to come up. PowerShell's Invoke-WebRequest pays 4 s per miss on localhost today.
- 主要言語
- C#
- スター
- 18.5k
- フォーク
- 5.8k
- 平均マージ
- 2日 18時間
- マージ済み PR(30日)
- 588
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dotnet/runtime のほかの issue
-
area-CodeGen-coreclr untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
dotnet/runtime#138181 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area-System.Collections untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
dotnet/runtime#138090 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area-System.Text.Json untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
dotnet/runtime#138089 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area-Setup untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
dotnet/runtime#137376 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area-System.Memory untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
dotnet/runtime#137334 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
Add `net10.0`オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
dotnet-outdated/dotnet-outdated#871 ·
メンテナーはふだん 1 日以内に返信
-
triage/untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
unoplatform/uno#26676 ·
メンテナーはふだん 1 日以内に返信
-
.NET bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
jhaizhou-ops/S2Arm#2177 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信