What is the difference between idle-timeout and request timeout in akka http configuration?
Asked Answered
S

2

7

I went to the documentation and found out these # The time after which an idle connection will be automatically closed. # Set to infinite to completely disable idle connection timeouts. idle-timeout = 10 s

# Defines the default time period within which the application has to
# produce an HttpResponse for any given HttpRequest it received.
# The timeout begins to run when the *end* of the request has been
# received, so even potentially long uploads can have a short timeout.
# Set to `infinite` to completely disable request timeout checking.
#
# If this setting is not `infinite` the HTTP server layer attaches a
# `Timeout-Access` header to the request, which enables programmatic
# customization of the timeout period and timeout response for each
# request individually.
request-timeout = 20 s

I have a scenario where my server takes more than 10 seconds to process a response but before sending the HTTPResponse the TCP connection between the client and server is timed out because of idle timeout.

Although the connection is idle at the moment but the request is still processing.

I thought this was the responsibility of response timeout?

Can anyone in this context explain me the difference between idle-timeout and response-timeout?

Sapele answered 22/6, 2017 at 7:6 Comment(0)
R
3

Documentation is a bit confusing, I have run the experiments based on that :

idle-timeout: It is the max time a connection can sit idle. It behaves the same as the Request timeout. Example :

idle-timeout = 1 s

Application has sent a request to 3rd party API and connection established, But 3rd party is not responding back. Then you will get a Timeout exception.

"akka.stream.scaladsl.TcpIdleTimeoutException"

connecting-timeout: 500 ms. It indicates the maximum time (500 ms) in which an Http connection must be established.

Restful answered 18/6, 2020 at 0:6 Comment(0)
K
2

From the documentation and more details here

  # The idle timeout for an open connection after which it will be closed
  # Set to null or "infinite" to disable the timeout, but notice that this
  # is not encouraged since timeout are important mechanisms to protect your
  # servers from malicious attacks or programming mistakes.
  idleTimeout = 75 seconds

If looks like you are setting the idle timeout lower than the request timeout, so it takes precedence. Your idle timeout settings should be longer than the request timeout, so for each request, the request timeout decides when to close the connection.

Kinghorn answered 20/1, 2018 at 17:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.