产生java.net.SocketException:连接被对方复位
问题描述:
07-28 12:41:40.953: W/System.err(3386): java.net.SocketException: Connection reset by peer
07-28 12:41:40.953: W/System.err(3386): at org.apache.harmony.luni.platform.OSNetworkSystem.read(Native Method)
07-28 12:41:40.953: W/System.err(3386): at dalvik.system.BlockGuard$WrappedNetworkSystem.read(BlockGuard.java:273)
07-28 12:41:40.953: W/System.err(3386): at org.apache.harmony.luni.net.PlainSocketImpl.read(PlainSocketImpl.java:458)
07-28 12:41:40.953: W/System.err(3386): at org.apache.harmony.luni.net.SocketInputStream.read(SocketInputStream.java:85)
07-28 12:41:40.953: W/System.err(3386): at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:166)
07-28 12:41:40.953: W/System.err(3386): at java.io.BufferedInputStream.read(BufferedInputStream.java:225)
07-28 12:41:40.953: W/System.err(3386): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.readLine(HttpURLConnectionImpl.java:660)
07-28 12:41:40.953: W/System.err(3386): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.readResponseHeaders(HttpURLConnectionImpl.java:690)
07-28 12:41:40.953: W/System.err(3386): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.retrieveResponse(HttpURLConnectionImpl.java:1040)
07-28 12:41:40.953: W/System.err(3386): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:512)
07-28 12:41:40.953: W/System.err(3386): at com.android.epaisa.Info.submitInfo(Info.java:168)
07-28 12:41:40.953: W/System.err(3386): at com.android.epaisa.Info.onClick(Info.java:62)
07-28 12:41:40.953: W/System.err(3386): at android.view.View.performClick(View.java:2485)
07-28 12:41:40.953: W/System.err(3386): at android.view.View$PerformClick.run(View.java:9080)
07-28 12:41:40.953: W/System.err(3386): at android.os.Handler.handleCallback(Handler.java:587)
07-28 12:41:40.953: W/System.err(3386): at android.os.Handler.dispatchMessage(Handler.java:92)
07-28 12:41:40.953: W/System.err(3386): at android.os.Looper.loop(Looper.java:130)
07-28 12:41:40.953: W/System.err(3386): at android.app.ActivityThread.main(ActivityThread.java:3687)
07-28 12:41:40.953: W/System.err(3386): at java.lang.reflect.Method.invokeNative(Native Method)
07-28 12:41:40.953: W/System.err(3386): at java.lang.reflect.Method.invoke(Method.java:507)
07-28 12:41:40.953: W/System.err(3386): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
07-28 12:41:40.960: W/System.err(3386): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
07-28 12:41:40.960: W/System.err(3386): at dalvik.system.NativeStart.main(Native Method)
,其中错误发生线路是
Line where error is occurring is
InputStream is = conn.getInputStream();
连接是有效的流
请帮我解决这个问题。试图访问一个JSON对象我收到此错误。在手动检查URL结果如预期。我试图发送JPG图片文件COM pressing将它转换成字节数组,然后通过互联网发送。
感谢和问候,
Please help me in solving the issue . I am getting this error while trying to access a JSON object. upon manually checking the URL the result is as expected. I am trying to send an jpg image file compressing it converting it into byte array and then sending over the internet. Thanks and Regards,
答
专家错误是因为由于缓慢的互联网连接的响应,从而连接被越来越复位按在后端编码超时的发生。
Guys the error was occurring because of timeout due to slow response in the internet connection and thus the connection was getting reset as per the coding at the backend.