xfire 客户端超时设置不起作用 Java.net
代码如下
service = (T) new XFireProxyFactory().create(serviceModel, url);
int TIMEOUT = 10000;
HttpClientParams params = new HttpClientParams();
params
.setParameter(HttpClientParams.USE_EXPECT_CONTINUE,
Boolean.FALSE);
params.setParameter(HttpClientParams.CONNECTION_MANAGER_TIMEOUT,
Long.parseLong(TIMEOUT+""));
params.setParameter(HttpClientParams.SO_TIMEOUT, TIMEOUT);
Client client = Client.getInstance(service);
client.setTimeout(TIMEOUT);
client.setProperty(CommonsHttpMessageSender.HTTP_CLIENT_PARAMS, params);
client.setProperty(CommonsHttpMessageSender.HTTP_TIMEOUT, TIMEOUT+"");
client.setProperty(CommonsHttpMessageSender.DISABLE_EXPECT_CONTINUE,
"true");
client.setProperty(CommonsHttpMessageSender.DISABLE_KEEP_ALIVE, "true");
但是 超时不起作用
页面上仍然长时间的载入中 且控制台日志如下:
2011-01-24 15:55:11,361 INFO [HttpMethodDirector.java:434] : I/O exception caught when processing request: Connection timed out
2011-01-24 15:55:11,362 INFO [HttpMethodDirector.java:440] : Retrying request
2011-01-24 15:58:20,350 INFO [HttpMethodDirector.java:434] : I/O exception caught when processing request: Connection timed out
2011-01-24 15:58:20,351 INFO [HttpMethodDirector.java:440] : Retrying request
2011-01-24 16:01:29,338 INFO [HttpMethodDirector.java:434] : I/O exception caught when processing request: Connection timed out
2011-01-24 16:01:29,339 INFO [HttpMethodDirector.java:440] : Retrying request
2011-01-24 16:04:38,327 ERROR [HttpChannel.java:144] : java.net.ConnectException: Connection timed out
org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: Couldn't send message.
org.codehaus.xfire.fault.XFireFault: Couldn't send message.
似乎隔三分钟 就去连接一下 第四次终于放弃了
上一篇: zf框架的zend_cache缓存使用方法_PHP教程
下一篇: PHP常用实用函数_PHP教程