java.net.SocketTimeoutException: Tomcat 下读取超时 [英] java.net.SocketTimeoutException: Read timed out under Tomcat

查看:123
本文介绍了java.net.SocketTimeoutException: Tomcat 下读取超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于 Tomcat 的 Web 应用程序.我间歇性地收到以下异常,

I have a Tomcat based web application. I am intermittently getting the following exception,

Caused by: java.net.SocketTimeoutException: Read timed out
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:150)
    at java.net.SocketInputStream.read(SocketInputStream.java:121)
    at org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:532)
    at org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:501)
    at org.apache.coyote.http11.InternalInputBuffer$InputStreamInputBuffer.doRead(InternalInputBuffer.java:563)
    at org.apache.coyote.http11.filters.IdentityInputFilter.doRead(IdentityInputFilter.java:124)
    at org.apache.coyote.http11.AbstractInputBuffer.doRead(AbstractInputBuffer.java:346)
    at org.apache.coyote.Request.doRead(Request.java:422)
    at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:290)
    at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:431)
    at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:315)
    at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:200)
    at java.nio.channels.Channels$ReadableByteChannelImpl.read(Channels.java:385)

不幸的是,我无法访问客户端,所以我只是想确认可能发生的各种原因,

Unfortunately I don't have access to the client, so I am just trying to confirm on various reasons this can happen,

  1. 服务器正在尝试从请求中读取数据,但数据从客户端到达的时间超过了超时值.这里的超时通常是 Tomcat 连接器 → connectionTimeout 属性.

  1. Server is trying to read data from the request, but its taking longer than the timeout value for the data to arrive from the client. Timeout here would typically be Tomcat connector → connectionTimeout attribute.

客户端设置了读取超时,而服务器的响应时间比该超时要长.

Client has a read timeout set, and server is taking longer than that to respond.

我经历过的一个线程说,如果启用了keepalive,这可能会在高并发情况下发生.

One of the threads I went through, said this can happen with high concurrency and if the keepalive is enabled.

对于#1,我设置的初始值是 20 秒,我已将其提高到 60 秒,将进行测试,看看是否有任何变化.

For #1, the initial value I had set was 20 sec, I have bumped this up to 60sec, will test, and see if there are any changes.

同时,如果你们中的任何人可以就此提供专家意见,那将非常有帮助.或者就此而言,您可以想到可能导致此问题的任何其他原因.

Meanwhile, if any of you guys can provide you expert opinion on this, that'l be really helpful. Or for that matter any other reason you can think of which might cause this issue.

推荐答案

服务器正在尝试从请求中读取数据,但它花费的时间比数据从客户端到达的超时值要长.这里的超时通常是 tomcat connector -> connectionTimeout 属性.

Server is trying to read data from the request, but its taking longer than the timeout value for the data to arrive from the client. Timeout here would typically be tomcat connector -> connectionTimeout attribute.

正确.

客户端设置了读取超时,而服务器的响应时间比该超时要长.

Client has a read timeout set, and server is taking longer than that to respond.

没有.这会导致客户端超时

No. That would cause a timeout at the client.

我经历过的一个线程说,如果启用了keepalive,这可能会在高并发情况下发生.

One of the threads i went through, said this can happen with high concurrency and if the keepalive is enabled.

这显然是猜测,而且完全不正确.当且仅当在超时内没有数据到达时才会发生.时期.加载和保活和并发与它无关.

That is obviously guesswork, and completely incorrect. It happens if and only if no data arrives within the timeout. Period. Load and keepalive and concurrency have nothing to do with it whatsoever.

这只是意味着客户端没有发送.您无需担心.浏览器客户端以各种奇怪的方式来来去去.

It just means the client isn't sending. You don't need to worry about it. Browser clients come and go in all sorts of strange ways.

这篇关于java.net.SocketTimeoutException: Tomcat 下读取超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆