Skip to content

HTTP outbound: Fix hanging on server-first traffic - #7193

Merged
RPRX merged 2 commits into
XTLS:mainfrom
Shilmoon:fix/http-outbound-server-first
Oct 21, 2026
Merged

RPRX merged 2 commits into
XTLS:mainfrom
Shilmoon:fix/http-outbound-server-first

Conversation

@Shilmoon

Copy link
Copy Markdown
Contributor

The HTTP outbound waits for the first client payload before it sends CONNECT. With protocols where the server talks first (FTP, SMTP, MySQL, or SSH clients that wait for the server banner, which is probably what #3459 ran into with XShell/MobaXterm) the client waits for the greeting and Xray waits for the client, so the connection hangs until one side gives up.

v2fly has the same two changes: v2fly/v2ray-core#1517 and the Buffered() drain in its connectHTTP1.

Tests (both fail on main):

  • TestHTTPOutboundServerFirst in testing/scenarios: dokodemo → HTTP outbound → HTTP inbound → a server that sends first.
  • TestHTTP1TunnelKeepsDataReadWithResponse in proxy/http: the proxy writes the 200 and the greeting in one write.

Also tried with real binaries: FTP to vsftpd 3.0.5 through the HTTP outbound, via Xray's HTTP inbound, squid 6.13 and Caddy 2.11.7 forward_proxy, and from a SOCKS inbound with sniffing, times out on main and works with this change. Plain HTTP latency and throughput are unchanged.

Read the first payload with a 500 ms timeout like the VLESS outbound, so
protocols where the server speaks first (SMTP, FTP, MySQL) no longer wait
forever for client data before CONNECT is sent.

Keep tunneled bytes that bufio read together with the CONNECT 200 response
instead of dropping them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@RPRX
RPRX requested a review from Fangliding October 18, 2026 08:02
@RPRX

RPRX commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

只记得 VLESS 明确修过这个,看了下 #3459 还真是 HTTP outbound

Core 里的这种等待时间以后得改成 range,比如 500~1000ms,并且再加个随机 padding,不过可能得等正式版 Vision Seed 了

@RPRX RPRX changed the title HTTP outbound: Fix hang on server-first protocols HTTP outbound: Fix hanging on server-first traffic Oct 21, 2026
@RPRX
RPRX merged commit 061c2df into XTLS:main Oct 21, 2026
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.

3 participants