I just got a SocketTimeOutException in my app while parsing a http response inputstream.
Here the exception:
In the HC_ResponseSuccess sub I just initialize the SAX parser and parse the inputstream:
What happend here? Wasn't the data copletely received? A part of the XML got parsed correctly but it seems that the rest is missing.
How can I prevent such an error? Do I have to put the sax.Parse(...) into a try..catch block?
Here the exception:
B4X:
weatherupdater_hc_responsesuccess (java line: 189)
java.net.SocketTimeoutException
at org.apache.harmony.luni.net.PlainSocketImpl.read(PlainSocketImpl.java:461)
at org.apache.harmony.luni.net.SocketInputStream.read(SocketInputStream.java:85)
at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:103)
at org.apache.http.impl.io.AbstractSessionInputBuffer.read(AbstractSessionInputBuffer.java:134)
at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:174)
at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:188)
at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:178)
at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:516)
at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:479)
at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:318)
at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:275)
at anywheresoftware.b4a.objects.SaxParser.parse(SaxParser.java:47)
at anywheresoftware.b4a.objects.SaxParser.Parse(SaxParser.java:40)
at de.amberhome.weather.weatherupdater._hc_responsesuccess(weatherupdater.java:189)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:105)
at anywheresoftware.b4a.BA$1.run(BA.java:210)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3835)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
at dalvik.system.NativeStart.main(Native Method)
In the HC_ResponseSuccess sub I just initialize the SAX parser and parse the inputstream:
B4X:
Sub HC_ResponseSuccess (Response As HttpResponse, TaskId As Int)
sax.Initialize
sax.Parse(Response.GetInputStream, "SAX")
[...]
What happend here? Wasn't the data copletely received? A part of the XML got parsed correctly but it seems that the rest is missing.
How can I prevent such an error? Do I have to put the sax.Parse(...) into a try..catch block?