simpligility / ksoap2-android

ksoap2-android - SOAP support for Android
http://simpligility.github.io/ksoap2-android/
Other
543 stars 247 forks source link

HttpTransPortSE - Timeout Not Respected #131

Open jpock76 opened 5 years ago

jpock76 commented 5 years ago

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 commented 5 years ago

wanna send a PR to improve this?

jpock76 commented 5 years ago

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 commented 5 years ago

Sent a small PR which should fix this

cemsbr commented 4 years ago

A workaround is: httpTransport.setReadTimeout(timeout);

MMulthaupt commented 2 years ago

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: https://github.com/simpligility/ksoap2-android/blob/0d2b179da0e243c3047eba10ece80d44adde56e1/ksoap2-j2se/src/main/java/org/ksoap2/transport/HttpsTransportSE.java#L30-L31 https://github.com/simpligility/ksoap2-android/blob/0d2b179da0e243c3047eba10ece80d44adde56e1/ksoap2-j2se/src/main/java/org/ksoap2/transport/HttpTransportSE.java#L91-L93