Axis2 ServiceClient选项忽略超时 [英] Axis2 ServiceClient options ignore timeout

查看:219
本文介绍了Axis2 ServiceClient选项忽略超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在版本中使用Axis2:

I am using Axis2 in version:

Implementation-Version: 1.7.0-SNAPSHOT
Implementation-Vendor-Id: org.apache.axis2
Implementation-Vendor: The Apache Software Foundation
Jenkins-Build-Number: 1847

我想将ServiceClient的超时设置为2000毫秒,这是我们的代码:

I want to set the timeout of the ServiceClient to 2000 milliseconds, this is our code:

Options options = new Options();
options.setTo(new EndpointReference(getUserServiceEndPoint()));
options.setProperty(Constants.Configuration.ENABLE_REST,
        Constants.VALUE_TRUE);
// setting timeout to 2 second should be sufficient, if the server is
// not available within the 3 second interval you got a problem anyway
options.setTimeOutInMilliSeconds(2000);

ServiceClient sender = new ServiceClient();
sender.engageModule(new QName(Constants.MODULE_ADDRESSING)
        .getLocalPart());
sender.setOptions(options);
OMElement getSessionResult = sender
        .sendReceive(getPayloadMethodGetSession());

但是我仍然在日志中看到:

However I still see in the logs:

org.apache.axis2.AxisFault:主机在超时60000毫秒内不接受连接

org.apache.axis2.AxisFault: The host did not accept the connection within timeout of 60000 ms

它真的需要60秒。所以错误信息不仅仅是错误的,似乎只是忽略了超时选项而且它总是使用默认选项。

And it really takes also 60 seconds. So the error message is not just wrong, it seems like the timeout option is just ignored and it always uses the default one.

任何人都有类似的问题?

Anybody had a similar issue ?

谢谢你
Sebastian

Thanks
Sebastian

推荐答案

我能够解决问题(虽然它看起来有些重复我)

I was able to resolve the issue (although it looks somehow duplicated to me)

int timeOutInMilliSeconds = 2000;
options.setTimeOutInMilliSeconds(timeOutInMilliSeconds);
options.setProperty(HTTPConstants.SO_TIMEOUT, timeOutInMilliSeconds);
options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, timeOutInMilliSeconds);

Sebastian

Sebastian

这篇关于Axis2 ServiceClient选项忽略超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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