Hi guys,
My app reads html code from a website to extract useful data. It worked on my phone with Android 2.3.6 but got this error on another phone with Android 4.0.4
It's strange because when I changed to another internet connection (via wifi) the error never occurred. When I changed back, it got error again. :BangHead: Can you explain to me? Thank you so much.
The Http library is based on Apache HttpClient. The suggestion in this link is for a different API. Are you calling Request.Release when your done with it?
The Http library is based on Apache HttpClient. The suggestion in this link is for a different API. Are you calling Request.Release when your done with it?
I tried to Response.Release before calling new request but it didn't help. Here the error from Log Cat:
channel_hc_responsesuccess (java line: XXXX)
java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:542)
at libcore.io.IoBridge.recvfrom(IoBridge.java:506)
at java.net.PlainSocketImpl.read(PlainSocketImpl.java:488)
at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46)
at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:240)
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.ChunkedInputStream.read(ChunkedInputStream.java:161)
at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:159)
at java.io.InputStreamReader.read(InputStreamReader.java:244)
at java.io.Reader.read(Reader.java:145)
at org.apache.http.util.EntityUtils.toString(EntityUtils.java:135)
at anywheresoftware.b4a.http.HttpClientWrapper$HttpResponeWrapper.GetString(HttpClientWrapper.java:471)
at com.myapp.channel._hc_responsesuccess(channel.java:1021)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:165)
at anywheresoftware.b4a.BA$3.run(BA.java:301)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4514)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
at dalvik.system.NativeStart.main(Native Method)
Caused by: libcore.io.ErrnoException: recvfrom failed: ECONNRESET (Connection reset by peer)
at libcore.io.Posix.recvfromBytes(Native Method)
at libcore.io.Posix.recvfrom(Posix.java:131)
at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:164)
at libcore.io.IoBridge.recvfrom(IoBridge.java:503)
java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
Seems like your server breaks the connection. Note that Response.GetString is deprecated and should not be used (though I don't think that it is related to this error).
Sub RequestSource
ProgressDialogShow2("Please wait...", True)
Dim job1 As HttpJob
job1.Initialize("Job1", Me)
job1.Download("http://www.google.com")
End Sub
Sub JobDone (Job As HttpJob)
If Job.Success = True Then
Select Job.JobName
Case "Job1"
Msgbox(Job.GetString, "Source")
End Select
Else
ToastMessageShow("Can not connect to server", True)
End If
Job.Release
End Sub
don't know if it is of importance or related but can Msgbox (being modal) be used in your above routine? Try with log or toast to see if the code works.
Hi Moster67,
I used Msgbox to make sure this code work. It's really strange because I cut this code to create new project then it worked but in my old project it didn't. I really don't know what happen.
No, and I don't know how to destroy HttpUtils2Service.
I added 2 modules HttpJob.bas & HttpUtils2Service.bas into my old project. I edited my code to use HttpUtils2 but I got this message. I don't know how to deal with it. May I send you my project to take a look?