Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 745
Atiq Avatar asked Jun 22 '17 07:06

Atiq


Video Answer


2 Answers

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.

like image 89
Shiva Garg Avatar answered Sep 18 '22 03:09

Shiva Garg


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.

like image 26
user1242321 Avatar answered Sep 17 '22 03:09

user1242321