kvin024 / ksoap2-android

Automatically exported from code.google.com/p/ksoap2-android
0 stars 0 forks source link

If there is no internet connection, the speed of the response is very slow when I call HttpTransportSE.call functions #123

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello, everyone:
Maybe, I found a issue of HttpTransportSE.call.
My android client need to access asp.net web service(asmx) in the local 
intranet (Not Internet). The terminal can connect to the server via a router. I 
found:
1. When the terminal can access internet via router, HttpTransportSE.call can 
be returned quickly.
2. If I break off the internet connection, it means all of the machines 
(terminal, server and router) can not access the internet, HttpTransportSE.call 
runs very slowly.
3. The length of the data (sent to the server and received from the server 
) is very short, less than 256 bytes.
4. The core code is shown as below:
String strLoginID = new String("");
String strNameSpace = "http://tempuri.org/"; 
String strMethodName = "Login";             
String strURI = "http://192.168.10.1:8080/ForAndroid/Service.asmx"; 
String strSoapAction = strNameSpace + strMethodName;  
HttpTransportSE transport = new HttpTransportSE(strURI); 
transport.debug = false; 
SoapObject soapObeject = new SoapObject(strNameSpace, strMethodName); 
soapObeject.addProperty("userid", strAccount);
soapObeject.addProperty("pwd", strPassword);
SoapSerializationEnvelope envelope = new 
SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = transport; 
envelope.dotNet = true; 
envelope.setOutputSoapObject(soapObeject); 
try { 
    transport.call(strSoapAction, envelope); 
    strLoginID = envelope.getResponse().toString(); 
} catch (IOException e) {
    //...
    return;
} catch (XmlPullParserException e) {
    // ...
    return;
} 
5. I use ksoap2-android-assembly-2.6.4-jar-with-dependencies.jar and the 
version of the Android OS is 2.3.4.

Thank you very much.

Original issue reported on code.google.com by taowei...@163.com on 2 Jun 2012 at 2:56

GoogleCodeExporter commented 9 years ago
Can you test if this affect the general network connection on android adversely 
as well .. I have a feeling it is not related to ksoap2 itself but rather the 
Android network stack and your setup.. 

Original comment by mosa...@gmail.com on 4 Jun 2012 at 4:07

GoogleCodeExporter commented 9 years ago
1. Can you test if this affect the general network connection on android 
adversely as well..
OK, I tested it. The general network connection is OK while there is no 
internet connection. It means that the android client terminal(e.g. 
192.168.1.101) can access the server(e.g. 192.168.1.102) via a router, all of 
them are in a local network(Intranet).
2. I have a feeling it is not related to ksoap2 itself but rather the Android 
network stack and your setup.
What do you mean about Android network stack and setup? Could you please give 
me some suggestions?

Thank you very much.

Original comment by taowei...@163.com on 5 Jun 2012 at 2:56

GoogleCodeExporter commented 9 years ago
Thanks for  providing more details. My question would is e.g. accessing the 
same server in the browser also slow? If that is the case it would think it is 
an Android class that causes the problem and therefore there is not much 
ksoap2-android can do.

In general there is pretty much no direct network connection related code in 
ksoap2-android. It is just using the classes provided by the runtime. 

If the browser is also slow you will have to see what sort of proxy setting or 
DNS or whatever is necessary to make it faster and hopefully that will fix 
ksoap2 performance as well. 

If not you will have to debug into the ksoap2 source code and see where it 
spends the time.. 

Original comment by mosa...@gmail.com on 5 Jun 2012 at 8:09

GoogleCodeExporter commented 9 years ago
1. My question would is e.g. accessing the same server in the browser also slow?
The same server can be accessed in the browser quickly, but calling of 
HttpTransportSE.call is still very slow.
2. I found the error information from the logcat window: D/SntpClient(1119): 
request time failed: java.net.SocketTimeoutException: Try again. So, I guess 
that does ksoap2 need access the internet during call HttpTransportSE.call 
function?
3. I modified the following code : [HttpTransportSE transport = new 
HttpTransportSE(strURI);]  to [HttpTransportSE transport = new 
HttpTransportSE(null, strURI);], but the error is also occurred. 

Original comment by taowei...@163.com on 6 Jun 2012 at 2:59

GoogleCodeExporter commented 9 years ago
这个问题终于解决了,跟踪时发现Android 
API里的HttpUrlConnection这个类getOutputStream和getInputStream很慢,不�
��ksoap2的问题,冤枉他了

解决的途径是
1. 
不启用无线路由的DHCP服务,使用静态IP,服务器都使用静态IP
连路由
2. 在平板上设置静态IP,点设置 >> 无线和网络 >> Wi-Fi设置 >> 
点击菜单按钮(屏幕下边三个按钮最左边一个) >> 高级 >> 
使用静态IP 勾上 >> 设置 
IP地址,网关,网络掩码,域名1(一定记得输入0.0.0.0),最后��
�击菜单按钮选保存

只要保证平板使用静态IP连上无线路由,并且域名为0.0.0.0,��
�卓就不会再花20S+通过DNS解释什么域名了。
我在多台平台平板上测试多没有问题

Original comment by herbert0...@gmail.com on 2 Aug 2012 at 3:37

GoogleCodeExporter commented 9 years ago
This problem finally solved, Android API HttpUrlConnection's method 
getOutputStream and getInputStream are slow after tracking , not ksoap2 wronged.

Ways to solve
(1) do not enable the wireless router's DHCP service, use a static IP, servers 
use static IP routing even
Static IP, set in the android pad: settings >> on the >> Advanced >> Wireless 
Network >> Wi-Fi settings >> click the menu button (three buttons for screen 
below the left-most one) >> static IP hook, then set IP address, gateway, 
network mask, domain name (must input 0.0.0.0), and finally click the menu 
button to choose the save.

As long as to ensure that the android pad to use a static IP connected to the 
wireless router, and domain is 0.0.0.0, Android will no longer spend 20S + to 
explain what domain names through DNS.
Multiple platforms test are all ok.

Original comment by herbert0...@gmail.com on 2 Aug 2012 at 3:43

GoogleCodeExporter commented 9 years ago

Original comment by mosa...@gmail.com on 21 Aug 2012 at 7:59

GoogleCodeExporter commented 9 years ago
I think the way you have solved the problem is not the best. It is not 
acceptable the fact that the DHCP system of the router has to be disabled in 
order for the application to work. 
Is not there another way to solve it? 

Thank you.

Original comment by j...@mi-traslados.com.uy on 8 Jun 2013 at 10:41

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I have the same problem. I connect to a .net webservice and call several 
methods.
Sometimes, it happens that the HttpTransportSE#call function correctly 
communicate with the webservice, but it throws a SocketTimeoutException 
nevertheless the .NET web-method was called and returned correctly.

I'm using the ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar version.

Original comment by paolo.mo...@gmail.com on 4 Oct 2013 at 1:04