How to configure tomcat to handle bad HTTP clients?

We are launching jBoss 5.1, which in turn uses the Tomcat servlet container.

We have seen cases where bad HTTP clients open a socket, make an HTTP request, do not read all the data, and cannot close the connection.

The result is that tomcat threads block endless writes to the output stream:

SocketOutputStream.socketWrite0(FileDescriptor, byte[], int, int) SocketOutputStream.socketWrite(byte[], int, int) SocketOutputStream.write(byte[], int, int) InternalOutputBuffer.realWriteBytes(byte[], int, int) ByteChunk.flushBuffer() ByteChunk.append(byte[], int, int) InternalOutputBuffer$OutputStreamOutputBuffer.doWrite(ByteChunk, Response) IdentityOutputFilter.doWrite(ByteChunk, Response) InternalOutputBuffer.doWrite(ByteChunk, Response) Response.doWrite(ByteChunk) OutputBuffer.realWriteBytes(byte[], int, int) ByteChunk.append(byte[], int, int) OutputBuffer.writeBytes(byte[], int, int) OutputBuffer.write(byte[], int, int) CoyoteOutputStream.write(byte[], int, int) 

How to configure these connections for timeout?

+4
source share
3 answers

You can put Apache in front of it. Really.

+1
source

There seems to be no timeout when using the default connector. NioConnector seems to have write timeouts (although there are some TODO comments in the source environment).

So, if you want to do some testing, use the NioConnector and set the undocumented parameter "timout" - the source code may mean that disableUploadTimeout must be "false" for it to take effect.

Basically, in your server.xml, change the http Connector element to something like this:

 <Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol" timeout="60000" disableUploadTimeout="false" connectionTimeout="20000" redirectPort="8443" /> 

(From the server.xml file by default tomcat 6.0.20, the attributes timeout and disableUploadTimeout were added, and the protocol attribute was changed to "org.apache.coyote.http11.Http11NioProtocol")

mod_jk seems to have multiple timeouts and should work more closely with apache than mod_proxy.

+1
source

Is there anything on this page that helps regarding timeouts? http://tomcat.apache.org/connectors-doc/generic_howto/timeouts.html

0
source

All Articles