Search code examples
androidksoap2

Calling a Web Service using ksoap2 is very slow (just sometimes)


In my application, I call some Web Serices (WS) using ksoap2 library and almost all o the time it works fast. But sometimes, the call of the WS is very slow.

I have a code like this:

beforecall = System.currentTimeMillis();
androidHttpTransport1.call(NameSpaces.NAMESPACE+UserWSMethodName.GETUSERINFO,envelope1);
Log.d("soapdebug","call duration="+(System.currentTimeMillis()-beforecall));

And generally I get 1 or 2 seconds (Max), but sometimes I get 11 seconds... And when the calls are too slow, it happens for all WS, and after a while (hours, for instance) it comes back to normal and become fast...

In wireshark, I see that for each call, the time elapsed between the call() method is invoked and the time where the server establish the the TCP connection with a [SYN] packet, is about 10 seconds so it is during this time that the time is spent, but I don't understand why this happen just sometimes.

What could be causing the problem? It could be a device configuration?


Solution

  • What I have made to solve this problem was just reboot the router where the mobile device is connected.