golang/go

net/http/httputil: ReverseProxy: time out long-idle upgraded connections

Open

#75,830 建立於 2025年10月9日

在 GitHub 查看
 (5 留言) (0 反應) (0 負責人)Go (133,883 star) (19,008 fork)batch import
LibraryProposalNeedsDecisionhelp wanted

描述

ReverseProxy automatically handles upgraded connections, such as WebSocket connections. When a proxied request results in a 101 Switching Protocols response, ReverseProxy switches to proxying raw bytes through the connection.

We should perhaps have some form of idleness detection, so a dead connection isn't left around consuming resources indefinitely. Currently, if one half of the connection vanishes without closing the TCP connection, ReverseProxy will leave the connection active until the OS times out the connection.

This probably needs to be off by default, since I'm certain someone is depending on ReverseProxy proxying long-lived but mostly-idle connections.

Since this will need to be configurable, it'll need to go through the proposal process once there's a concrete design for the configuration knob.

貢獻者指南