9

This is a SpringBoot website. When I debug it in Chrome, I find that there is Keep-Alive: timeout=38 in the response header.

enter image description here

I guess it means the max idle time a TCP connection can hold. This is from here

timeout: indicating the minimum amount of time an idle connection has to be kept opened (in seconds). Note that timeouts longer than the TCP timeout may be ignored if no keep-alive TCP message is set at the transport level.

Question 1: How to change the default value in SpringBoot? I update the appllicaiton.property and set server.connection-timeout=1200000000, no affect.

Question 2: If the browser side does not contain "Proxy-Connection: keep-alive" in the header, which means that it will not reuse the TCP connection. Now, if a TCP connection works for more than 38s because the content is too much to transfer from the browser to server, will it be closed by the server?

Edit: This morning when I debug Chrome for the same website, the keep-alive in response header is gone. That is werid. Why is it not there all the time?

Robin Sun
  • 1,352
  • 3
  • 20
  • 45
  • It depends on which embedded server you are using. Example - Tomcat, undertow and jetty have their own specification of changing keep-alive flag. Let me know which one you are using and we can find documentation around that. – Imran Oct 22 '18 at 02:09
  • https://stackoverflow.com/questions/24895812/how-to-force-tomcat-server-to-send-the-keep-alive-header-in-http-response – clevertension Oct 22 '18 at 02:46
  • @Imran, it is the default SpringBoot embeded server. I guess it is tomcat. – Robin Sun Oct 22 '18 at 05:44

1 Answers1

1

If you're using the default server, that's Tomcat. Here's the config property you're looking for: server.tomcat.keep-alive-timeout

More: https://docs.spring.io/spring-boot/docs/current/reference/html/application-properties.html#appendix.application-properties.server

Josh M.
  • 26,437
  • 24
  • 119
  • 200