corwin42 Expert Licensed User Longtime User Aug 18, 2011 #1 I just got a SocketTimeOutException in my app while parsing a http response inputstream. Here the exception: Code: Copy 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: Code: Copy 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?
I just got a SocketTimeOutException in my app while parsing a http response inputstream. Here the exception: Code: Copy 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: Code: Copy 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?
Erel B4X founder Staff member Licensed User Longtime User Aug 18, 2011 #2 The actual stream is only downloaded during parsing. You can increase the timeout value or better do it asynchronously (you may still need to increase the timeout value). HttpUtils can help you if you want to do it asynchronously. Upvote 0
The actual stream is only downloaded during parsing. You can increase the timeout value or better do it asynchronously (you may still need to increase the timeout value). HttpUtils can help you if you want to do it asynchronously.
corwin42 Expert Licensed User Longtime User Aug 18, 2011 #3 Thanks for the quick answer. I think I will switch over to asynchronously processing. Upvote 0