Java tomcat中connectionTimeout的含义

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30839941/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 10:13:27  来源:igfitidea点击:

Meaning of connectionTimeout in tomcat

javaeclipsetomcat

提问by St.Antario

What does that parameter mean for tomcat. It was declared in server.xmlas follows:

该参数对 tomcat 意味着什么。声明server.xml如下:

 <Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>

So, I tried to change it

所以,我试图改变它

 <Connector connectionTimeout="2" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>

and didn't notice any effect. I expected that each page the load takes for more than 2 milliseconds would produce 504 - connection timeout error. But it didn't. I'm using eclipse and modify that file through it.

并没有注意到任何影响。我预计加载时间超过 2 毫秒的每个页面都会产生 504 - 连接超时错误。但它没有。我正在使用 eclipse 并通过它修改该文件。

采纳答案by this.user3272243

Taken from here: https://tomcat.apache.org/tomcat-7.0-doc/config/http.html

取自这里:https: //tomcat.apache.org/tomcat-7.0-doc/config/http.html

connectionTimeout

The number of milliseconds this Connector will wait, after accepting a connection, for the request URI line to be presented. Use a value of -1 to indicate no (i.e. infinite) timeout. The default value is 60000 (i.e. 60 seconds) but note that the standard server.xml that ships with Tomcat sets this to 20000 (i.e. 20 seconds). Unless disableUploadTimeout is set to false, this timeout will also be used when reading the request body (if any).

connectionTimeout

此连接器在接受连接后等待显示请求 URI 行的毫秒数。使用值 -1 表示没有(即无限)超时。默认值为 60000(即 60 秒),但请注意,Tomcat 附带的标准 server.xml 将其设置为 20000(即 20 秒)。除非 disableUploadTimeout 设置为 false,否则在读取请求正文(如果有)时也会使用此超时。

回答by Vali7394

This parameter is there specifically to fight one type of Denial-Of-Service attack, whereby some malicious client(s) create a TCP connection to the server (which has theeffect of reserving some resources on the server for handling this connection), and then just sit there without sending any HTTP request on that connection. By making this delay shorter, you shorten the time during which the server resources are allocated, to serve a request that will never come.

此参数专门用于对抗一种类型的拒绝服务攻击,即某些恶意客户端创建到服务器的 TCP 连接(其作用是在服务器上保留一些资源来处理此连接),然后只是坐在那里而不在该连接上发送任何 HTTP 请求。通过缩短此延迟,您可以缩短分配服务器资源的时间,以处理永远不会到来的请求。