2

I am trying to use Keep-Alive with Spring Boot, using configuration from: https://stackoverflow.com/a/31461882/5585182

# application.properties
server.connection-timeout=60000

When I want to verify with Apache Benchmark connections are not kept alive.

ab -v 2 -k -c 1 -n 10 http://localhost:8080/api/test

I get the following output:

---
GET /api/test HTTP/1.0
Connection: Keep-Alive
Host: localhost:8080
User-Agent: ApacheBench/2.3
Accept: */*


---
LOG: header received:
HTTP/1.1 200
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Content-Type: application/json;charset=UTF-8
Date: Wed, 27 Dec 2017 15:17:54 GMT
Connection: close

As you can see it responded with Connection: close anyone got a clue why this is not working?

Albert Bos
  • 2,012
  • 1
  • 15
  • 26

1 Answers1

0

ab is using HTTP/1.0 instead of HTTP/1.1. It sends a keep-alive header, so it should still work, as Tomcat is supporting keep-alive with HTTP/1.0:

https://tomcat.apache.org/tomcat-9.0-doc/config/http.html#HTTP/1.1_and_HTTP/1.0_Support

But I tested it here too. No keep-alive with ab but when tested with telnet, it works with SpringBoot/tomcat:

$ telnet 127.0.0.1 80
Trying 127.0.0.1...
Connected to 127.0.0.1
Escape character is '^]'.
GET / HTTP/1.1
Host: www.myhost.de

HTTP/1.1 200 
Cache-Control: no
...
Connection still open
Janning Vygen
  • 8,877
  • 9
  • 71
  • 102