Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] keep alive configuration

keep-alive was part of the HTTP spec.

HTTP/0.9 - no keep-alive supported. (also no longer a supported HTTP version in Jetty 9+)
HTTP/1.0 - default is no-keep-alive (close connection after each request), User-agent can use request header "Connection: keep-alive" to request keep-alive.
HTTP/1.1 - default is persistent connections ("keep-alive" is no longer a term used in HTTP).  User-agent can request no persistent connections using "Connection: close". (A User-agent request header of "Connection: keep-alive" has no meaning in this version)
HTTP/2 - default is persistent connections.

In all of the above behaviors, the specs are clear that the Server can close the connection for its own reasons, even it the client expects the connection to persist.

The idea of a server side configuration for connection "keep-alive" really doesn't makes sense in any version of HTTP ... with a server that honors the HTTP spec properly.

If the switch exists to enable "keep-alive", then it has no meaning in HTTP/1.1 and HTTP/2 (this is default behavior).  To enable "keep-alive" in HTTP/1.0 requires the user-agent to send the "Connection: keep-alive" header (server cannot force this).
If the switch exists to disable "keep-alive", then it has no need in HTTP/1.1 (just add the "Connection: close" header to your responses, in a filter or rewrite rule if you want).  HTTP/2 cannot disable it, and HTTP/1.0 is already behaving the way you want.

So, in short, if you want persistent connections, use HTTP/1.1 (or HTTP/2), don't specify "Connection: close" (on client request headers or server response headers), and don't do anything that violates the HTTP spec (as that will be an error that closes the connection).

- Joakim

Joakim Erdfelt / joakim@xxxxxxxxxxx

On Thu, Aug 3, 2017 at 10:06 PM, anurag gupta <anurag.11feb@xxxxxxxxx> wrote:
Is there a possibility to configure keep-alive on jetty ?

--
Regards
Anurag

_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users


Back to the top