weblogic上HttpURLConnection的超时
来源:互联网 发布:yy网络兼职频道 编辑:程序博客网 时间:2024/05/29 11:40
System.setProperty("sun.net.client.defaultConnectTimeout", "500");
System.setProperty("sun.net.client.defaultReadTimeout", "500");
在jdk1.4.2_05下测http,上面的代码是生效的,https没有试。
好像jdk1.4.2.12解决了https的问题,见jdk1.4的bug清单。
HttpURLConnection的实现类正常情况下是sun.net.www.protocol.http.HttpURLConnection
而weblogic8下是weblogic.net.http.SOAPHttpURLConnection。
SOAPHttpURLConnection是weblogic.net.http.HttpURLConnection的子类
System.setProperty("weblogic.client.SocketConnectTimeoutInSecs", "500");在sp4不管用
-Dweblogic.client.SocketConnectTimeoutInSecs=500也不管用。
在http://forums.oracle.com/forums/thread.jspa?threadID=766767里有人说
Well, it depends on the OS and JVM used. If Weblogic is using Native library (socket Muxer) for remote communication then socketconnectTimeout only helps when thread is stuck on "Socket.connect() method, but it would never timeout the socket if it is stuck on "Socket.read()" because the Control does not return to JVM till OS level TCP/IP connection returns.
To resolve this issue, try to timeout TCP connections at OS level using OS parameters. Hopefully BEA would come with some resolution of this issue in future release
应该使用"weblogic.http.client.defaultConnectTimeout"属性
在weblogic9的weblogic.net.http.HttpURLConnection类里找到如下的代码
defaultConnectTimeout = Integer.getInteger("weblogic.http.client.defaultConnectTimeout", -1).intValue();
而在weblogic8.1 sp4的该类里没找到,或许sp5就有了(见http://download.oracle.com/docs/cd/E13222_01/wls/docs81///javadocs/weblogic/net/http/HttpURLConnection.html)
现在的问题是,对于这种问题可不可以通过超时设定来释放线程。weblogic中,RJVM(即server之间,可能是admin-to- managed,也可能是managed-to-managed)之间,连接的协议有两类五种,两类是http、t3,五种是http、https、 t3、t3s、local。超时设定时协议层面的东西,所以我们这里只讨论http和t3。
对于t3,从上面的trace可以看到,连接的创建从ServerURL.findOrCreateRJVM()开始,这个方法有多种实现,不同的实现使用不同的timeout,客户端程序可以通过向environment中set一个叫做weblogic.jndi.requestTimeout的变量,如果不做设定,则使用系统默认的DEFAULT_CONNECTION_TIMEOUT,这是个静态值(0)。而在上面的stacktrace中,我们可以看到,environment是在RemoteChannelServiceImpl中定义的,这个environment对于客户而言是不可配置的,而weblogic自己的这个env中是不设定requesttimeotu的,也就是,无论哪种方式,connectionTimeout/readTimeout对于t3,都是不可配置的,而且默认是没有超时的。
而对于http,HTTPClientJVMConnection在创建HttpURLConnection的时候,会读取系统环境变量中的如下两个变量,
[b]weblogic.http.client.defaultReadTimeout[/b]
[b]weblogic.http.client.defaultConnectTimeout[/b]
如果没有设定,这两个变量的默认值均为-1,即不做timeout。如果我们作了设定,这两个值即读超时、连接超时都会生效。这两个值可以用于解决上述的问题。
weblogic.http.client.defaultReadTimeout
weblogic.http.client.defaultConnectTimeout
哪里可以设置呢?
举例:
Windows平台:
set JAVA_OPTIONS=-Dweblogic.http.client.defaultReadTimeout=30 -Dweblogic.http.client.defaultConnectTimeout=30 %JAVA_OPTIONS%
UNIX/Linux平台:
JAVA_OPTIONS="-Dweblogic.http.client.defaultReadTimeout=30 -Dweblogic.http.client.defaultConnectTimeout=30 $JAVA_OPTIONS"
export JAVA_OPTIONS
System.setProperty("sun.net.client.defaultReadTimeout", "500");
在jdk1.4.2_05下测http,上面的代码是生效的,https没有试。
好像jdk1.4.2.12解决了https的问题,见jdk1.4的bug清单。
HttpURLConnection的实现类正常情况下是sun.net.www.protocol.http.HttpURLConnection
而weblogic8下是weblogic.net.http.SOAPHttpURLConnection。
SOAPHttpURLConnection是weblogic.net.http.HttpURLConnection的子类
System.setProperty("weblogic.client.SocketConnectTimeoutInSecs", "500");在sp4不管用
-Dweblogic.client.SocketConnectTimeoutInSecs=500也不管用。
在http://forums.oracle.com/forums/thread.jspa?threadID=766767里有人说
Well, it depends on the OS and JVM used. If Weblogic is using Native library (socket Muxer) for remote communication then socketconnectTimeout only helps when thread is stuck on "Socket.connect() method, but it would never timeout the socket if it is stuck on "Socket.read()" because the Control does not return to JVM till OS level TCP/IP connection returns.
To resolve this issue, try to timeout TCP connections at OS level using OS parameters. Hopefully BEA would come with some resolution of this issue in future release
应该使用"weblogic.http.client.defaultConnectTimeout"属性
在weblogic9的weblogic.net.http.HttpURLConnection类里找到如下的代码
defaultConnectTimeout = Integer.getInteger("weblogic.http.client.defaultConnectTimeout", -1).intValue();
而在weblogic8.1 sp4的该类里没找到,或许sp5就有了(见http://download.oracle.com/docs/cd/E13222_01/wls/docs81///javadocs/weblogic/net/http/HttpURLConnection.html)
现在的问题是,对于这种问题可不可以通过超时设定来释放线程。weblogic中,RJVM(即server之间,可能是admin-to- managed,也可能是managed-to-managed)之间,连接的协议有两类五种,两类是http、t3,五种是http、https、 t3、t3s、local。超时设定时协议层面的东西,所以我们这里只讨论http和t3。
对于t3,从上面的trace可以看到,连接的创建从ServerURL.findOrCreateRJVM()开始,这个方法有多种实现,不同的实现使用不同的timeout,客户端程序可以通过向environment中set一个叫做weblogic.jndi.requestTimeout的变量,如果不做设定,则使用系统默认的DEFAULT_CONNECTION_TIMEOUT,这是个静态值(0)。而在上面的stacktrace中,我们可以看到,environment是在RemoteChannelServiceImpl中定义的,这个environment对于客户而言是不可配置的,而weblogic自己的这个env中是不设定requesttimeotu的,也就是,无论哪种方式,connectionTimeout/readTimeout对于t3,都是不可配置的,而且默认是没有超时的。
而对于http,HTTPClientJVMConnection在创建HttpURLConnection的时候,会读取系统环境变量中的如下两个变量,
[b]weblogic.http.client.defaultReadTimeout[/b]
[b]weblogic.http.client.defaultConnectTimeout[/b]
如果没有设定,这两个变量的默认值均为-1,即不做timeout。如果我们作了设定,这两个值即读超时、连接超时都会生效。这两个值可以用于解决上述的问题。
weblogic.http.client.defaultReadTimeout
weblogic.http.client.defaultConnectTimeout
哪里可以设置呢?
举例:
Windows平台:
set JAVA_OPTIONS=-Dweblogic.http.client.defaultReadTimeout=30 -Dweblogic.http.client.defaultConnectTimeout=30 %JAVA_OPTIONS%
UNIX/Linux平台:
JAVA_OPTIONS="-Dweblogic.http.client.defaultReadTimeout=30 -Dweblogic.http.client.defaultConnectTimeout=30 $JAVA_OPTIONS"
export JAVA_OPTIONS
- weblogic上HttpURLConnection的超时
- weblogic上的webservice
- HttpURLConnection超时设置
- HttpURLConnection超时处理
- Java HttpURLConnection超时问题
- Java HttpURLConnection超时问题
- Java HttpURLConnection超时问题
- HttpURLConnection超时处理
- HttpURLConnection超时处理
- HttpURLConnection超时处理
- JAVA HttpURLConnection超时处理
- Java HttpURLConnection超时问题
- HttpURLConnection超时处理
- Java HttpURLConnection超时问题
- httpurlconnection设置超时
- 解决HttpURLConnection setConnectTimeout超时无响应的问题
- 解决HttpURLConnection setConnectTimeout超时无响应的问题
- android HttpUrlConnection 设置超时无效,等待时间很长的问题
- CSharp3新特性之五:匿名类型
- Ubuntu10.04设置开机自动登入root帐户
- SG1实验7
- dwarf 调试信息格式入门
- JVM调优总结(四)---垃圾回收面临的问题
- weblogic上HttpURLConnection的超时
- CSharp3新特性之六:分部方法
- mj评《龙门飞甲》-8.5分
- php程序post请求提交过去后,页面无反应
- escape()、encodeURI()、encodeURIComponent()区别详解
- Java多核线程笔记-volatile的原理与技巧
- 常用mysql 命令
- MVC设计模式解释
- WinCE 基于Wlan的TCP/IP通信