sozu-proxy / sozu

Sōzu HTTP reverse proxy, configurable at runtime, fast and safe, built in Rust. It is awesome!
https://www.sozu.io/
GNU Affero General Public License v3.0
3.12k stars 193 forks source link

Fix TCP hang on connection failure #1062

Closed Wonshtrum closed 10 months ago

Wonshtrum commented 10 months ago

When a TcpSession failed to connect to a backend (max retries reached, no backend available, connection error...) the error was ignored and the Session would remain dormant until a timeout occurred. This let the client connection hang for no apparent reason even though Sozu knew the connection could not be established. The first commit homogenizes the TCP session and HTTP state handling of connection results, ensuring every case is treated. In the case of TCP, any connection error will trigger a session close, letting the client know the connection failed with minimal delay. The second commit homogenizes the TCP states to use SessionResult when possible, reducing the number of cases to treat in the upper layers. They still do not implement SessionState.