简体   繁体   English

Tomcat连接超时是否触发500到HTTP客户端?

[英]Does Tomcat connection timeout triggers a 500 to the HTTP client?

In my setup i see intermittently a number of errors as follows: 在我的设置中,我间歇性地看到许多错误,如下所示:

2016-07-07 12:22:04,248 ERROR  [com.biltz.krieg.endpoints.controllers.ControllerBase] (http-nio-8080-exec-25) Caught Exception:
java.io.EOFException: Unexpected EOF read on the socket
        at org.apache.coyote.http11.InternalNioInputBuffer.fill(InternalNioInputBuffer.java:152)
        at org.apache.coyote.http11.InternalNioInputBuffer$SocketInputBuffer.doRead(InternalNioInputBuffer.java:177)
        at org.apache.coyote.http11.filters.IdentityInputFilter.doRead(IdentityInputFilter.java:110)
        at org.apache.coyote.http11.AbstractInputBuffer.doRead(AbstractInputBuffer.java:413)
        at org.apache.coyote.Request.doRead(Request.java:460)

The times of those errors coincide with the access log showing the following: 这些错误的时间与显示以下内容的访问日志一致:

[07/Jul/2016:12:36:36] 172.31.2.246 POST /v1/blitz 500 59.499 133
[07/Jul/2016:12:37:29] 172.31.2.246 POST /v1/blitz 500 59.186 133
[07/Jul/2016:12:39:41] 172.31.2.246 POST /v1/blitz 500 59.889 133

The interesting about the above it every request that triggered a 500 from the server took about 60 seconds to be processed. 有趣的是,从服务器触发500的每个请求花费了大约60秒来处理。

60 seconds is how Tomcat connection timeout is configured: Tomcat连接超时的配置时间为60秒:

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

So it seems really related to the this timeout but I don't understand why as the documentation about the connection timeout says this 因此,这似乎与该超时有关,但是我不明白为什么,因为有关连接超时的文档指出了这一点

The number of milliseconds this Connector will wait, after accepting a connection, for the request URI line to be presented. 接受连接后,此连接器将等待呈现请求URI行的毫秒数。 Use a value of -1 to indicate no (ie infinite) timeout. 使用值-1表示没有(即无限)超时。 The default value is 60000 (ie 60 seconds) but note that the standard server.xml that ships with Tomcat sets this to 20000 (ie 20 seconds). 默认值为60000(即60秒),但请注意,Tomcat附带的标准server.xml将此值设置为20000(即20秒)。

The above means to me that after this timeout occurs, the TCP/HTTP connection would be closed without sending anything. 以上对我而言意味着,在发生此超时之后,TCP / HTTP连接将关闭而不发送任何内容。 Am i wrong? 我错了吗?

Does Tomcat connection timeout triggers a 500 to the HTTP client? Tomcat连接超时是否触发500到HTTP客户端?

Are you using Apache as a front end for Tomcat? 您是否将Apache用作Tomcat的前端? I had a similar problem, and adjusting the timeout in the Apache configuration solved the problem. 我遇到了类似的问题,并且在Apache配置中调整超时解决了该问题。

Specifically, I am running Tomcat 6.0.24 with incoming requests redirected from port 80 by Apache 2.2.15 on a CentOS 6.6 virtual machine. 具体来说,我正在运行Tomcat 6.0.24,并在CentOS 6.6虚拟机上通过Apache 2.2.15从端口80重定向了传入请求。 I adjusted this line in my Apache config file (/etc/httpd/conf/httpd.conf): 我在Apache配置文件(/etc/httpd/conf/httpd.conf)中调整了这一行:

#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 60

The default is apparently 60 seconds. 默认值显然是60秒。 I increased it to 120 seconds. 我将其增加到120秒。 This solved my problem. 这解决了我的问题。

Just to be clear, I did not modify the <Connector> element in my Tomcat configuration file (/etc/tomcat6/server.xml) as you mentioned. 为了清楚起见,我没有像您提到的那样修改我的Tomcat配置文件(/etc/tomcat6/server.xml)中的<Connector>元素。 I left it at the default, which is apparently 20 seconds for release versions of Tomcat: 我将其保留为默认值,对于Tomcat的发行版,默认值为20秒:

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

This implies that the 500 errors I was receiving (and presumably yours as well) were not caused by this timeout. 这意味着我收到的500个错误(大概也是您的错误)不是由此超时引起的。 In particular, although I left my Tomcat timeout at the default of 20 seconds here, I have services that grind for over a minute and still return a good response. 特别是,尽管我在这里将Tomcat超时的默认时间设置为20秒,但我的服务经过了一分钟的磨细,仍然返回了良好的响应。 It was only the Apache configuration that was killing them if they went over 60 seconds. 如果超过60秒,只有Apache配置会杀死它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM