Socket Reuse Can Cause Multiple CONNECT Requests on Same TCP Connection
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 25/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- nodejs, typescript
- 領域
- networking
調査の方向性
Start with the socket-reuse comment near chain.js:52 and the httpAgent option that prepareRequestFunction accepts, then check how anonymizeProxy builds its upstream connection. Reproducing needs an upstream proxy and a tcpdump capture of repeated CONNECT requests on one socket. The open question is whether reuse is a bug or expected, so a maintainer decision on that comes before any change.
索引モデルが issue の本文から書いたものです。
説明
Summary
When using ProxyChain without specifying a custom httpAgent in prepareRequestFunction or using anonimyzeProxy, Node.js's default HTTP agent (which has keepAlive: true) may reuse TCP sockets for multiple CONNECT requests to the upstream proxy. This can cause intermittent connection failures when using proxy-chain to forward requests to an upstream proxy server.
Background
According to RFC 9110 Section 9.3.6:
A tunnel is closed when a tunnel intermediary detects that either side has closed its connection: the intermediary MUST attempt to send any outstanding data that came from the closed side to the other side, close both connections, and then discard any remaining data left undelivered.
After a successful CONNECT response (200), the TCP connection becomes a tunnel and should be treated as opaque to HTTP semantics. I may be misunderstanding the specification, but it seems that sending another CONNECT request through an already-established tunnel might violate this principle.
Reproducing
This issue was initially observed when using anonymizeProxy(), which creates a ProxyChain server that forwards to upstream proxies.
This appears more frequently on slower machines where there's more temporal overlap between requests.
import ProxyChain from "proxy-chain";
import puppeteer from "puppeteer";
const proxyUrl = await ProxyChain.anonymizeProxy(
"http://user:[email protected]:8080"
);
const browser = await puppeteer.launch({
args: [`--proxy-server=${proxyUrl}`],
});
const page = await browser.newPage();
await page.goto("https://www.github.com/");
// Intermittent failures observed here
We then used tcpdump to capture traffic and observe socket re-use.
Workaround
The issue can be resolved by providing a custom httpAgent with keepAlive: false:
import http from 'http';
const noReuseAgent = new http.Agent({
keepAlive: false,
maxSockets: Infinity,
maxFreeSockets: 0,
});
const server = new ProxyChain.Server({
prepareRequestFunction: () => ({
upstreamProxyUrl: "http://user:[email protected]:8080",
requestAuthentication: false,
httpAgent: noReuseAgent, // Prevents socket reuse
}),
});
With this configuration, each CONNECT request gets a fresh TCP connection to the upstream proxy, eliminating the intermittent failures.
Questions
I'd appreciate clarification on a few points:
-
Is this expected behavior? The comment in
chain.js:52mentions "Socket can be re-used by multiple requests" which suggests awareness of socket reuse, but I'm unsure if this refers to regular HTTP requests or CONNECT tunnels. -
Is my interpretation of the HTTP spec correct? I may be misunderstanding how CONNECT tunnels should work in the context of HTTP connection pooling.
-
Is socket reuse for CONNECT requests a common practice? Perhaps this behavior works fine with some upstream proxies and only certain implementations reject it.
- 主要言語
- TypeScript
- スター
- 1k
- フォーク
- 167
- 平均マージ
- 16時間 47分
- マージ済み PR(30日)
- 20
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apify/proxy-chain のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
apify/proxy-chain#635 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
apify/proxy-chain#634 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 12/100
apify/proxy-chain#633 ·
メンテナーはふだん 1 日以内に返信
-
good first issue low priority t-unblocking tech roadmap
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
apify/proxy-chain#632 ·
メンテナーはふだん 1 日以内に返信
-
low priority t-unblocking tech roadmap
難易度 3/5 半日 初心者へのやさしさ 28/100
apify/proxy-chain#631 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
apify/proxy-chain の issue をすべて見る
似ている issue
-
Create/import wallet form shows raw "password must be at least 1 characters" instead of the translated message対応中かも @CapThunder19 が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
joinmarket-webui/jam#1538 ·
メンテナーはふだん 1 日以内に返信
-
t0ggles
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
nolimits4web/swiper#8240 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
modelcontextprotocol/inspector#2723 ·
メンテナーはふだん 1 日以内に返信
-
status:approved type:bug
難易度 1/5 1時間未満 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信