rbrlnx
rbrlnx

Reputation: 286

Socket closed in network only v4.0 ksoap2

im using ksoap2 library, works fine but when i use android 4.0 and im over 3G, when i try to set the connection always the socket is closed. I was read is about connection keep-alive but i dont know how do set this property.

Any idea?

Upvotes: 1

Views: 560

Answers (3)

rolgalan
rolgalan

Reputation: 1661

Maybe too late four you, but I hope this would help to future people reaching here like me, getting crazy with the same problem.

It's an Android bug. Everything works right with WiFi, but it crashes on 3G. It happened to me on 4.1, but no problem on 4.2.2.

To solve it, you have to modify the file org.ksoap2.transport.HttpTransportSE (I've extended a new one and called it MyHttpTransportSE because I'm using ksoap2 assembly jar). Just override method public void call(String soapAction, SoapEnvelope envelope) commenting out the line:

    //connection.setRequestProperty("Connection", "close"); 

Of course, if you're working with SSL, you'll need to extend your own HttpsTransportSE from your new MyHttpTransportSE.

More details here: https://groups.google.com/forum/#!searchin/ksoap2-android/closed/ksoap2-

Upvotes: 2

Søren Lorentzen
Søren Lorentzen

Reputation: 866

Android 4.0 does not allow you to run internet communication on the main thread. Go with AsyncTask

You an read more here.

Alternatively, take a look at this question.

Upvotes: 0

rbrlnx
rbrlnx

Reputation: 286

In library source HttpConectionSE.java set property connection to keep-alive compile package and use.

Upvotes: 3

Related Questions