Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HttpTransPortSE - Timeout Not Respected #131

Open
jpock76 opened this issue Jun 21, 2019 · 5 comments · May be fixed by #134
Open

HttpTransPortSE - Timeout Not Respected #131

jpock76 opened this issue Jun 21, 2019 · 5 comments · May be fixed by #134

Comments

@jpock76
Copy link

jpock76 commented Jun 21, 2019

timeOut is passed to HttpTransportSE.

HttpTransportSE httpTransport = new HttpTransportSE(url, timeOut);

HttpTransportSE accepts the input into this constructor:
public HttpTransportSE(String url, int timeout) {
super(url, timeout);
}

super(url, timeout) - super is Transport.java. Looking into that, I find the constructor using only url, timeout.

public Transport(String url, int timeout) {
    this.timeout = 20000;
    this.readTimeout = 20000;
    this.xmlVersionTag = "";
    this.bufferLength = 262144;
    this.prefixes = new HashMap();
    this.url = url;
    this.timeout = timeout;

   *** line missing here should be
   this.readTimeout = timeout;
}

It seems there is a relatively new implementation of "readtimeout" that is not getting set to the timeout passed. Every other constructor signature used will set this.readtimeout = the passed timeout. So it would seem that without this.readtimeout getting set, it will always use the default which is 20 seconds.

To get around this I just call
HttpTransportSE httpTransport = new HttpTransportSE(null, url, timeOut);
Passing "null" to the proxy parameter, which forces it to use the method which properly sets this.readtimeout to the passed value. Testing with this change, my web service calls were no longer timing out at 20 seconds, but at 60 like I asked it to.

@mosabua
Copy link
Member

mosabua commented Jun 21, 2019

wanna send a PR to improve this?

@jpock76
Copy link
Author

jpock76 commented Jun 24, 2019

I would, but I am new on Github and not sure I am doing this right. The strange thing is when I compare my downloaded version, 3.6.4 in Android Studio, the Transport.java does not match the copy in ksoap2-android/ksoap2-base/src/main/java/org/ksoap2/transport/transport.java. I expected them to be the same, comparing latest to latest. Am I wrong? I also and completely unfamiliar with Maven.

@matpag matpag linked a pull request Jul 16, 2019 that will close this issue
@matpag
Copy link

matpag commented Jul 16, 2019

Sent a small PR which should fix this

@cemsbr
Copy link

cemsbr commented Nov 27, 2019

A workaround is: httpTransport.setReadTimeout(timeout);

@MMulthaupt
Copy link

MMulthaupt commented Dec 9, 2021

There are other programming errors around here as well. For example, HttpsTransportSE (Notice the s in Https) passes readTimeout value into contentLength parameter for the (String, int, String, int, int)-constructor which moves on to doing nothing at all with it in the base class; connection timeout gets set but not read timeout:

public HttpsTransportSE (String host, int port, String file, int connectTimeout, int readTimeout) {
super(HttpsTransportSE.PROTOCOL_FULL + host + ":" + port + file, connectTimeout, readTimeout);

public HttpTransportSE(String url, int timeout, int contentLength) {
super(url, timeout);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants