我应该在哪里开始调查SocketTimeoutException:读取超时 [英] Where should I start investigating SocketTimeoutException: Read timed out

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

问题描述

在日志中时不时地,我看到下面的堆栈跟踪其中,的HttpClient 插座超时试图访问文本/脚本从另一台服务器上的内容。我的问题是什么样的配置设置应该怎么检查Weblogic上运行我的J2EE应用程序,在Linux上?我专门找下。


  • JVM超时PARAMS

  • 的HttpClient PARAMS

  • 的Weblogic超时PARAMS或任何其他配置一样线程等的数量。

  • J2EE应用程序的设置,如servlet配置等。

  • 操作系统资源,如线程,文件处理和cpu

  • 可能影响套接字连接任何其他配置设置

  • 请问线程转储帮助?

下面是我的code

  HTT presponse httpClientResponse;
//做一些东西
httpClientResponse.getStatus code(); //这是它失败

这是堆栈跟踪

  java.net.SocketTimeoutException:读超时
在jrockit.net.SocketNativeIO.readBytesPinned(本机方法)
在jrockit.net.SocketNativeIO.socketRead(SocketNativeIO.java:32)
在java.net.SocketInputStream.socketRead0(SocketInputStream.java)
在java.net.SocketInputStream.read(SocketInputStream.java:129)
在HTTPClient.BufferedInputStream.fillBuff(BufferedInputStream.java:206)
在HTTPClient.BufferedInputStream.read(BufferedInputStream.java:126)
在HTTPClient.StreamDemultiplexor.read(StreamDemultiplexor.java:356)
在HTTPClient.RespInputStream.read(RespInputStream.java:147)
在HTTPClient.RespInputStream.read(RespInputStream.java:108)
在HTTPClient.Response.readResponseHeaders(Response.java:1123)
在HTTPClient.Response.getHeaders(Response.java:846)
在HTTPClient.Response.getStatus code(Response.java:331)
在HTTPClient.RetryModule.responsePhase1Handler(RetryModule.java:92)
在HTTPClient.HTT presponse.handleResponseImpl(HTT presponse.java:872)
在HTTPClient.HTT presponse.access $ 000(HTT presponse.java:62)
在HTTPClient.HTT presponse $ 2.run(HTT presponse.java:839)
在HTTPClient.HTT presponse $ 2.run(HTT presponse.java:837)

HTTPClient.HttpClientConfiguration.doAction(HttpClientConfiguration.java:666)
在HTTPClient.HTT presponse.handleResponse(HTT presponse.java:837)
在HTTPClient.HTT presponse.getStatus code(HTT presponse.java:242)

感谢

我将更新与下面的调查结果,我的问题。


  1. 没有明确的超时值的HttpClient 设置,这意味着HTTP
    服务器会话超时可能会采取一种效果。

  2. SO_TIMEOUT 的HttpClient 0,这意味着它应该无限期等待。


解决方案

轨道1

根据的javadoc HttpClient的似乎并不具备有套接字超时的默认值。要回答你的更新问题 - 会话超时不会在这里的影响。 WebLogic的默认值是30分钟会话超时。

服务器会话超时重新presents的时间量的HttpSession 将在内存,如果要保留用户没有访问的服务器

套接字超时是时间保持服务器套接字打开量,同时数据被传输给调用者。这甚至可能是服务器仍在处理和写回的数据,但它采取偏长,客户刚刚超时等待它。

某些链接显示此默认为60秒,但的javadoc不说什么,在任何情况下,你可以将此值设置为类似120秒,看看是否有帮助。

<一个href=\"http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/params/HttpConnectionParams.html#setSoTimeout(int\">http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/params/HttpConnectionParams.html#setSoTimeout(int)

您需要的是时间超时 - 如果这是明确的。含义 - 做30秒,60秒或5分钟发出的请求后,这些错误出现在哪里?

我想改变SO_TIMEOUT再试

第2道 - OS参数

有用于NDD值推荐的BEA参数支配多久传入连接保持打开,以及有多少进行排队等。在Solaris上这些都是由运行了

  / 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上我的经验是默认值是不够的,他们需要被调升东亚银行(Oracle)的推荐

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

是否启用HTTP访问日志服务器上?做这些失败的请求出现任何响应字节大小,还是他们表现出0响应大小?什么错误code或HTTP返回状态code?

或许这些超时的是不是在所有记录在访问日志?

在这里,我假设上发生的超时外部服务器也WebLogic中,如果没有 - 这个问题被定向到外部服务器团队的等效平台

** **其他

通常线程转储帮助,但线程转储应采取的是有一个超时问题在服务器上。你是在客户端和读取响应出来的时候你已经成功地获得了连接,它次。因此,在外部服务器超载?缺乏线程? CPU高?太多的并发请求?

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 timeout params
  • HttpClient params
  • Weblogic timeout params or any other config like number of threads etc.
  • J2EE Application settings like servlet config etc.
  • Operating system resources like threads, file handlers and cpu
  • Any other config settings that might influence the socket connection
  • Would thread dumps help?

Here's my code

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

and this is the stacktrace

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) 

Thanks

I will be updating my question with the FINDINGS below.

  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

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.

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.

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)

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?

I would change the SO_Timeout and try again

Track 2 - OS parameters

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 

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

Track 3: Weblogic / External Access Logs

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?

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.

** Others **

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:读取超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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