代码之家  ›  专栏  ›  技术社区  ›  johnstok

如何配置tomcat来处理坏的HTTP客户机?

  •  4
  • johnstok  · 技术社区  · 15 年前

    我们已经看到一些坏的HTTP客户机会打开一个套接字,发出HTTP请求,无法读取所有数据,并且无法关闭连接的情况。

    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)
    

    如何将这些连接配置为超时?

    3 回复  |  直到 15 年前
        1
  •  1
  •   ChssPly76    15 年前

    你可以把 Apache

        2
  •  1
  •   nos    15 年前

    使用默认连接器时似乎没有任何超时。NioConnector似乎确实有写超时(尽管源代码中有一些TODO注释)。

    基本上,在server.xml中,将http连接器元素更改为如下内容:

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

    (从默认的tomcat 6.0.20 server.xml文件中,添加了timeout和disableUploadTimeout属性,并将protocol属性更改为“org.apache.coyote.http11.Http11NioProtocol”)

        3
  •  0
  •   JeeBee    15 年前