我应该从哪里开始调查 SocketTimeoutException: Read timed out [英] Where should I start investigating SocketTimeoutException: Read timed out

查看:59
本文介绍了我应该从哪里开始调查 SocketTimeoutException: Read timed out的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我时不时地在日志中看到以下堆栈跟踪,其中 HttpClient 套接字在尝试从另一台服务器访问 text/script 内容时超时.我的问题是,我应该为在 Linux 上的 Weblogic 上运行的 J2EE 应用程序检查哪些配置设置?我特别在寻找以下内容.

Every now and then I see following stacktrace in the log in which, HttpClient socket times out trying to access text/script content from another server. My question is what config settings should I check for my J2EE app running on Weblogic, on Linux? I am specifically looking for the following.

  • JVM 超时参数
  • HttpClient 参数
  • Weblogic 超时参数或任何其他配置,如线程数等.
  • J2EE 应用程序设置,如 servlet 配置等.
  • 操作系统资源,如线程、文件处理程序和 CPU
  • 任何其他可能影响套接字连接的配置设置
  • 线程转储有帮助吗?

这是我的代码

HTTPResponse httpClientResponse;
//do some stuff
httpClientResponse.getStatusCode(); // this is where it fails

这是堆栈跟踪

java.net.SocketTimeoutException: Read timed out
at jrockit.net.SocketNativeIO.readBytesPinned(Native Method)
at jrockit.net.SocketNativeIO.socketRead(SocketNativeIO.java:32)
at java.net.SocketInputStream.socketRead0(SocketInputStream.java)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at HTTPClient.BufferedInputStream.fillBuff(BufferedInputStream.java:206)
at HTTPClient.BufferedInputStream.read(BufferedInputStream.java:126)
at HTTPClient.StreamDemultiplexor.read(StreamDemultiplexor.java:356)
at HTTPClient.RespInputStream.read(RespInputStream.java:147)
at HTTPClient.RespInputStream.read(RespInputStream.java:108)
at HTTPClient.Response.readResponseHeaders(Response.java:1123)
at HTTPClient.Response.getHeaders(Response.java:846)
at HTTPClient.Response.getStatusCode(Response.java:331)
at HTTPClient.RetryModule.responsePhase1Handler(RetryModule.java:92)
at HTTPClient.HTTPResponse.handleResponseImpl(HTTPResponse.java:872)
at HTTPClient.HTTPResponse.access$000(HTTPResponse.java:62)
at HTTPClient.HTTPResponse$2.run(HTTPResponse.java:839)
at HTTPClient.HTTPResponse$2.run(HTTPResponse.java:837)
at
HTTPClient.HttpClientConfiguration.doAction(HttpClientConfiguration.java:666)
at HTTPClient.HTTPResponse.handleResponse(HTTPResponse.java:837)
at HTTPClient.HTTPResponse.getStatusCode(HTTPResponse.java:242) 

谢谢

我将使用以下发现更新我的问题.

I will be updating my question with the FINDINGS below.

  1. HttpClient 上没有明确的超时设置,这意味着 http服务器的会话超时可能正在生效.
  2. SO_TIMEOUT for HttpClient 是 0,这意味着它应该无限期地等待.
  1. There is no explicit timeout set on HttpClient which means that http session timeout of the server might be taking an effect.
  2. SO_TIMEOUT for HttpClient is 0 which means that it should wait indefinitely.

推荐答案

Track 1

根据 javadocs Httpclient 似乎没有 Socket 超时的默认值.要回答更新中的问题 - 会话超时在此处无效.Weblogic 的默认会话超时时间为 30 分钟.

As per the javadocs Httpclient does not seem to have have a default value of the Socket timeout. To answer the question in your update - the session timeout will not be in effect here. Weblogic's default is 30 minutes for session timeout.

服务器会话超时表示如果用户没有访问服务器,HttpSession将保留在内存中的时间量.

The server session timeout represents the amount of time the HttpSession will be retained in memory if the user has not accessed the server.

套接字超时是在将数据传输回调用方时保持服务器套接字打开的时间量.这甚至可能是服务器仍在处理和写回数据,但它花费了相当长的时间,并且客户端刚刚超时等待.

The socket timeout is the amount of time to keep the server socket open while data is being transferred back to the caller. This could even be the server is still processing and writing back data but it's taking rather long and the client has just timed out waiting for it.

某些链接建议此默认值为 60 秒,但 javadoc 没有说明任何内容,在任何情况下,您都可以将此值设置为 120 秒之类的值以查看是否有帮助

Some links suggest this default is 60 seconds but the javadocs dont say anything, in any case you can set this value to something like 120 seconds to see if it helps

http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/params/HttpConnectionParams.html#setSoTimeout(int)

您需要的是对超时进行计时 - 如果这很清楚.含义 - 这些错误是否在传出请求的 30 秒、60 秒或 5 分钟后出现?

What you need is to time the timeouts - if that's clear. Meaning - Do these errors appear after 30 sec, 60 sec or 5 minutes of the outgoing request?

我会更改 SO_Timeout 并重试

I would change the SO_Timeout and try again

轨道 2 - 操作系统参数

有推荐的 NDD 值的 BEA 参数,这些参数控制传入连接保持打开的时间以及排队的数量等等.在 Solaris 上,这些是通过运行

There are the recommended BEA parameters for NDD values which govern how long incoming connections are kept open and how many are queued and so on. On Solaris these are got by running

/usr/sbin/ndd -get /dev/tcp tcp_time_wait_interval 
/usr/sbin/ndd -get /dev/tcp tcp_conn_req_max_q 
/usr/sbin/ndd -get /dev/tcp tcp_conn_req_max_q0 
/usr/sbin/ndd -get /dev/tcp tcp_ip_abort_interval 
/usr/sbin/ndd -get /dev/tcp tcp_keepalive_interval 

您能否在 Oracle 文档中查看 Linux 上的等效命令,以及它们应设置的值.在 Solaris 上,我的经验是默认值是不够的,需要将它们升级到 BEA (Oracle) 建议

Can you check the Oracle docs for the equivalent commands on Linux, and what values they should be set at. On Solaris my experience is the defaults are not enough and they need to be upped to BEA (Oracle) recommendations

轨道 3:Weblogic/外部访问日志

您是否在服务器上启用了 HTTP 访问日志?这些失败的请求是否显示任何响应字节大小,还是显示 0 响应大小?返回什么错误代码或 HTTP 状态代码?

Have you enabled HTTP Access Logs on the server? Do these failed requests show up with any response byte size or do they show 0 response size? What error code or HTTP status code is returned?

或许这些超时的内容根本没有记录在访问日志中?

Or perhaps these timed out ones are not recorded in the access logs at all?

在这里,我假设发生超时的外部服务器也是 Weblogic,如果不是 - 这个问题是针对其等效平台的外部服务器团队的.

Here, I'm assuming the external server on which time outs occur is also Weblogic, if not - this question is directed to the external server team for their equivalent platform.

** 其他 **

通常线程转储有帮助,但线程转储应该在有超时问题的服务器上进行.您是客户端并且您已成功获得连接,然后在读取响应时超时.那么外部服务器是否过载?缺少线程?CPU高?并发请求过多?

Usually thread dumps help, but the thread dumps should be taken on the server which is having a timeout problem. You are the client and you have successfully obtained a connection, after that it times out when reading the response. So is the external server overloaded ? Lack of threads? CPU high? Too many concurrent requests?

这篇关于我应该从哪里开始调查 SocketTimeoutException: Read timed out的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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