After experimenting with my JBoss 5.1 server I noticed that the HTTP responses contain the Connection: close
header if the current thread is the last available one.
For instance if I set maxThreads="4"
in the HTTP connector config and perform more than 4 simulatenous requests, then:
Connection
header (meaning the connection can be reused by the client for future requests)Connection: close
header (meaning the client will have to create a new connection on a different port for the next request)I could not find any documentation for that. Is this behaviour explained somewhere? And is it possible to avoid it (i.e prevent this Connection: close
header) so that clients can reuse the sockets for future requests?
I had a quick look at Tomcat code (on which JbossWeb, the Web container of Jboss is base on).
It shows in the Http11Processor doesn't return from the process method if the connection is allowed to be kept alive. So kept alive connection are using a thread for the HTTP pool while the connection is open.
To prevent the pool to be emptied by non active kept alive connection, the thread pool is most probably (I have spotted some part of the code that may do it in the PooledSender) disabling the possibility to keep the connection open for the last thread in its pool before starting to process the new request. Otherwise it will be too easy to block Tomcat/Jboss by creating a limited number of kept-alive connection.