fix(relay): bound HTTP request reads - #281
Conversation
|
Downgrading to HTTP/1 only is quite bad. Did you research if there are not alternatives? |
98b512f to
ebb97df
Compare
Alternatives are:
|
|
This is a lot of complex code just for timeouts. Whats wrong with a simple hard deadline per-connection using existing exposed config options in hyper? Do we expect for there to be requests which take more than 30s to return? If so, could we just set the deadline to 60s instead, surely that is high enough for all requests which are going to be returned to return. Especially considering the payloads are tiny. I need convincing here that the complexity justifies the gain of allowing users of pkarr to indefinitely wait for dht responses. |
Nothing inherently. A hard per-connection deadline is simpler, but Hyper has no direct option for it. Its downside is that expiry kills valid in-flight requests and all multiplexed HTTP/2 streams. A sufficiently long deadline may be acceptable, but it differs from the current logic, which times out only while waiting for a request and lets active requests finish. |
|
@86667 cb0acc7 commit implements a smarter version of your idea. |
|
Aren't we going the wrong direction with this PR? Instead of Hyper managing the timeout, shouldn't we either
This feels like fighting symptoms instead of addressing the root cause. Other app working with pkarr will have the same issues. |
Enable Hyper's HTTP/1 header timeout and enforce a hard deadline on request bodies so stalled clients cannot retain file descriptors. Restrict the server to HTTP/1 because protocol auto-detection occurs before Hyper's header timeout.
Enforce a first-request deadline across protocol detection and the HTTP/2 handshake, then defer to protocol-specific header and body timeouts.
Replace the request-deadline stream wrapper with explicit Hyper connection handling so stalled clients cannot retain relay resources indefinitely. Bound concurrent connections, initial request headers, total connection age, and graceful draining. Preserve peer address extraction and apply protocol-specific HTTP/1 and HTTP/2 limits.
587cc1a to
3d27af4
Compare
The failure reproduced here happens before |
|
I am confused. Are you saying every hyper http server is bugged and easy to DDOS? |
Yes and no. Axum intentionally focuses on HTTP-level routing and handling, while protections such as connection, request, and body timeouts often span multiple layers and must be configured separately. |
Enable Hyper's HTTP/1 header timeout and enforce a hard deadline
on request bodies so stalled clients cannot retain file descriptors.
Restrict the server to HTTP/1 because protocol auto-detection occurs
before Hyper's header timeout.