Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timeouts for Axum server in the Tracker API #865

Conversation

josecelano
Copy link
Member

@josecelano josecelano commented May 15, 2024

Add timeouts for Axum server in the Tracker API:

  1. Timeout for the first request after opening the HTTP connection. 408 Request Timeout.
  2. HTTP1 header read timeout. Set a timeout for reading client request headers. If a client does not transmit the entire header within this time, the connection is closed.
  3. HTTP2 keep alive timeout: Sets a timeout for receiving an acknowledgement of the keep-alive ping. If the ping is not acknowledged within the timeout, the connection will be closed. Does nothing if http2_keep_alive_interval is disabled.
  4. HTTP2 keep alive interval: Sets an interval for HTTP2 Ping frames should be sent to keep a connection alive.
  5. Tower middleware which applies a timeout to requests.

The current implementation for the first timeout does not send any message (408 Request Timeout). It seems is also common practice.

To test the first case, you can open a connection to the API without sending any request with:

telnet 127.0.0.1 1212
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.

After 5 seconds you will see:

Connection closed by foreign host.

For advanced manual testing, you can use: https://github.com/josecelano/axum-server-timeout

We want to add timeouts for the Axum server configuration, in order to
close HTTP connections when the client doesn't send any request after
opening a HTTP connection.
…uests

Adds a timeout for the Tracker API for the time the server waits for the
first request from the client after openning a new HTTP connection.
@josecelano josecelano self-assigned this May 15, 2024
@josecelano josecelano added Security Publicly Connected to Security - Admin - Enjoyable to Install and Setup our Software labels May 15, 2024
Copy link

codecov bot commented May 15, 2024

Codecov Report

Attention: Patch coverage is 86.13861% with 14 lines in your changes are missing coverage. Please review.

Project coverage is 78.82%. Comparing base (8dc0520) to head (9e42a1a).

Files Patch % Lines
src/servers/custom_axum_server.rs 86.31% 13 Missing ⚠️
src/servers/apis/server.rs 66.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #865      +/-   ##
===========================================
+ Coverage    78.74%   78.82%   +0.08%     
===========================================
  Files          169      170       +1     
  Lines         9300     9398      +98     
===========================================
+ Hits          7323     7408      +85     
- Misses        1977     1990      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@josecelano josecelano force-pushed the 612-tracker-api-add-a-timeout-to-the-tls-handshake-waiting-for-headers-and-waiting-for-receiving-headers branch from 82c9792 to 9e42a1a Compare May 15, 2024 11:52
@josecelano
Copy link
Member Author

ACK 9e42a1a

@josecelano josecelano marked this pull request as ready for review May 15, 2024 11:52
@josecelano josecelano requested a review from da2ce7 May 15, 2024 11:52
@josecelano josecelano merged commit d0e66b7 into torrust:develop May 15, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- Admin - Enjoyable to Install and Setup our Software Security Publicly Connected to Security
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tracker API: Add a timeout to the TLS handshake, waiting for headers, and waiting for receiving headers
1 participant