Closed socket on mobile network on ICS

616 views
Skip to first unread message

jinzo

unread,
May 22, 2012, 7:19:20 PM5/22/12
to ksoap2-android
Hello,

I'm developing and maintaining a fairly simple application that uses
ksoap2-android (2.6.4 and previously 2.4) for some communication. But
now on ICS, the same code used before (and is still used on pre 4.0)
says "Socket is closed" when I try to make a call with HttpTransportSE
on mobile network - but when I do it on WiFi it works.

Any ideas what it could be?

Offending code (beware-not preatty):
https://bitbucket.org/jinzo/mporaba/src/02909642eb00/src/com/jinzo/mporaba/tasks/LoadFromSOAPTask.java

TL;DR:
- ksoap-android 2.6.4 based code works on anything pre 4.0 just fine
- on 4.0 WiFi works, Mobile network/data get Socket is closed error on
call

Thanks in advance,
Črnko

Manfred Moser

unread,
May 23, 2012, 2:59:27 PM5/23/12
to ksoap2-...@googlegroups.com
I have others had this issue report as well but personally it does not
appear on the apps I am working on. I have not investigated further ..

Anatoliy Shuba

unread,
May 24, 2012, 10:16:40 AM5/24/12
to ksoap2-android
I am using every day ksoap2-android library on my Archos 80 G9 (ICS
4.0.3 inside).
There is no "Socket is closed" issue observed when I am used 3G/2G
network as media.


On May 23, 9:59 pm, Manfred Moser <mosa...@gmail.com> wrote:
> I have others had this issue report as well but personally it does not
> appear on the apps I am working on. I have not investigated further ..
>
> On Tue, May 22, 2012 at 4:19 PM, jinzo <matjaz.cr...@gmail.com> wrote:
> > Hello,
>
> > I'm developing and maintaining a fairly simple application that uses
> > ksoap2-android (2.6.4 and previously 2.4) for some communication. But
> > now on ICS, the same code used before (and is still used on pre 4.0)
> > says "Socket is closed" when I try to make a call with HttpTransportSE
> > on mobile network - but when I do it on WiFi it works.
>
> > Any ideas what it could be?
>
> > Offending code (beware-not preatty):
> >https://bitbucket.org/jinzo/mporaba/src/02909642eb00/src/com/jinzo/mp...

Matjaž Črnko

unread,
May 24, 2012, 10:46:51 AM5/24/12
to ksoap2-...@googlegroups.com
Hello,

Interesting. Any pointers on how would I go debug this? Specificity, how to get more debug data/stack trace/exception?
(I looked at the wiki and found nothing interesting)

Thanks in advance,
Črnko

2012/5/23 Manfred Moser <mos...@gmail.com>

Manfred Moser

unread,
May 24, 2012, 12:02:10 PM5/24/12
to ksoap2-...@googlegroups.com
Hook up the source code of ksoap into your IDE and see what is
happening .. from my understanding it is an Android issue though...
and since I have not observed it myself I dont know too much about
what is going on..

Matjaž Črnko

unread,
May 30, 2012, 8:58:00 AM5/30/12
to ksoap2-...@googlegroups.com
I tried hooking up the source code of KSOAP2 and it looks like I'll have to hook up the Adnroid source code too as I'm no closer to a solution than I was before.
It looks like that I have pinpointed the error to HttpsURLConnection on a mobile connection. It baffles me because it works on WiFi (and yes I have checked, the ISP isn't doing any funny business on the proxy).
I also googled a ton but to no use - there're no mentions of this specific error I can find, only the NetworkOnMainThread (that's not it, because I'm using AsyncTask and it works on WiFi) and setDoOutput (also ruled out by working on WiFi). So it's something that Android wants on the mobile data network. I'll keep on digging and probably ask on SO or somewhere else. Because I'm mostly out of Ideas.

Manfred you said you had reports of that already? Here on the list or in private?

2012/5/24 Manfred Moser <mos...@gmail.com>

Manfred Moser

unread,
May 30, 2012, 11:38:57 AM5/30/12
to ksoap2-...@googlegroups.com
That was in private but I am sure I can share the results of their
investigation:



* Regarding the SSL bug in ICS: It's apparently triggered if you have
a proxy set on the android handset, and use https over a 3g
connection. This is clearly an Android bug, and probably nothing that
ksoap2 should account for. We will probably just let the app run
unencrypted over 3g as a workaround on the affected Android
versions...


Manfred again...

So at this stage this is what you might have to do. My application
works fine on 3g and wifi on ICS on a Nexus S and a Xoom on wifi so I
might be affected but can not tell at this stage..

Hope that helps..

manfred

Manfred Moser

unread,
Jun 1, 2012, 2:20:26 PM6/1/12
to ksoap2-...@googlegroups.com
Please try if the new 2.6.5 release fixes this issue and report back to us here. 

manfred

Matjaž Črnko

unread,
Jun 1, 2012, 2:41:50 PM6/1/12
to ksoap2-...@googlegroups.com
Hello,

I tried and upgraded to the new 2.6.5 release but unfortunately it still doesen't work. No matter if I use HttpTransportSE or HttpsTransporSE (both with https url as the service forces https). In 2 weeks I'll be finished with my school and if nothing else pops out I'll have time to debug this properly and try to come out with a workaround.

Thanks for your effort.
Črnko

2012/6/1 Manfred Moser <mos...@gmail.com>

Arnaud Bossmann

unread,
Jun 19, 2012, 5:28:26 AM6/19/12
to ksoap2-...@googlegroups.com
Did you add a header property "connection:close" in your request ? I had this problem

Matjaž Črnko

unread,
Jun 19, 2012, 7:19:11 AM6/19/12
to ksoap2-...@googlegroups.com
Hello,

no I did not add it manually. I'm constructing the request with SoapObject(NAMESPACE, METHOD_NAME) and adding a username and password properties. Then I'm using HttpTransportSE (or HttpsTransportSE).
Thanks for the tip - I'll look if somewhere the connection:close gets added.

2012/6/19 Arnaud Bossmann <arnaud....@gmail.com>

Matjaž Črnko

unread,
Jun 30, 2012, 10:17:13 AM6/30/12
to ksoap2-...@googlegroups.com
Hello,

I finally had some time to investigate further. And as it seems the solution is indeed removal of the connection: close; HTTP Property. So I commented it out in HttpTransportSE and now it looks like it works. Still have to do more extensive testst but looks promising. I'm also planing to investigate further.
Will report back here.

Thanks for all the help,
Črnkp

2012/6/19 Matjaž Črnko <matjaz...@gmail.com>

Ender Muab'Dib

unread,
Sep 12, 2013, 4:34:52 AM9/12/13
to ksoap2-...@googlegroups.com
Thank you very much Matjaž Črnko and Arnaud Bossmann for your answers. Finally I solved the very same problem commenting out the close connection property. I was unable to connect a server throught 3G but it was working fine with wifi. It failed with Andorid 4.1, but it worked in 4.2.2.
Maybe the maintainer could commit a new version of HttpTransportSE avoiding to set this property depending on the Android version...

In order to help further people coming here with this problem I copy the snippet of code that you need to remove/comment to work on some devices. The file is org.ksoap2.transport.HttpTransportSE

 public void call(String soapAction, SoapEnvelope envelope) throws IOException, XmlPullParserException {
[...]
 ServiceConnection connection = getServiceConnection();
        connection.setRequestProperty("User-Agent", "kSOAP/2.0");
        connection.setRequestProperty("SOAPAction", soapAction);
        connection.setRequestProperty("Content-Type", "text/xml");
       // connection.setRequestProperty("Connection", "close");  //this line!!!!
        connection.setRequestProperty("Content-Length", "" + requestData.length);
        connection.setRequestMethod("POST");
        connection.connect();
[...]
Reply all
Reply to author
Forward
0 new messages