Axis2 ServiceClient options ignore timeout

心已入冬 提交于 2019-12-06 07:20:13

问题


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

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: The host did not accept the connection within timeout of 60000 ms

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 ?

Thanks
Sebastian


回答1:


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




回答2:


Per API doc of Axis2 1.6.3, it is either the two properties or the timeOutInMillis like :

Options options = new Options();
options.setProperty(HTTPConstants.SO_TIMEOUT, new Integer(timeOutInMilliSeconds));
options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, new Integer(timeOutInMilliSeconds));

OR

options.setTimeOutInMilliSeconds(timeOutInMilliSeconds);

SOURCE: http://axis.apache.org/axis2/java/core/docs/http-transport.html



来源:https://stackoverflow.com/questions/13522686/axis2-serviceclient-options-ignore-timeout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!