Android HessianConnectionException SocketException (Connection reset by

......
04-21 11:42:16.682: E/AndroidRuntime(5642): Caused by: com.caucho.hessian.client.HessianConnectionException: 500: java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
04-21 11:42:16.682: E/AndroidRuntime(5642): at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:197)
04-21 11:42:16.682: E/AndroidRuntime(5642): at $Proxy0.findPlayersNearby(Native Method)
04-21 11:42:16.682: E/AndroidRuntime(5642): at com.u1wan.yaonimei.server.PlayerServiceServer.findPlayersNearby(PlayerServiceServer.java:259)
04-21 11:42:16.682: E/AndroidRuntime(5642): at com.u1wan.yaonimei.utils.SocialActivityTouchBaseAdapter.init(SocialActivityTouchBaseAdapter.java:135)
04-21 11:42:16.682: E/AndroidRuntime(5642): at com.u1wan.yaonimei.utils.SocialActivityTouchBaseAdapter.(SocialActivityTouchBaseAdapter.java:75)
04-21 11:42:16.682: E/AndroidRuntime(5642): at com.u1wan.yaonimei.activitys.social.NearbyActivity$NearyByRunnable.doInBackground(NearbyActivity.java:374)
04-21 11:42:16.682: E/AndroidRuntime(5642): at com.u1wan.yaonimei.activitys.social.NearbyActivity$NearyByRunnable.doInBackground(NearbyActivity.java:1)
04-21 11:42:16.682: E/AndroidRuntime(5642): at android.os.AsyncTask$2.call(AsyncTask.java:287)
04-21 11:42:16.682: E/AndroidRuntime(5642): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
04-21 11:42:16.682: E/AndroidRuntime(5642): ... 3 more
04-21 11:42:16.682: E/AndroidRuntime(5642): Caused by: java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
04-21 11:42:16.682: E/AndroidRuntime(5642): at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:598)
04-21 11:42:16.682: E/AndroidRuntime(5642): at libcore.io.IoBridge.recvfrom(IoBridge.java:560)
04-21 11:42:16.682: E/AndroidRuntime(5642): at java.net.PlainSocketImpl.read(PlainSocketImpl.java:490)
04-21 11:42:16.682: E/AndroidRuntime(5642): at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46)
04-21 11:42:16.682: E/AndroidRuntime(5642): at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:240)
04-21 11:42:16.682: E/AndroidRuntime(5642): at java.io.InputStream.read(InputStream.java:163)
04-21 11:42:16.682: E/AndroidRuntime(5642): at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:142)
04-21 11:42:16.682: E/AndroidRuntime(5642): at java.io.BufferedInputStream.read(BufferedInputStream.java:227)
04-21 11:42:16.682: E/AndroidRuntime(5642): at libcore.io.Streams.readAsciiLine(Streams.java:201)
04-21 11:42:16.682: E/AndroidRuntime(5642): at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:573)
04-21 11:42:16.682: E/AndroidRuntime(5642): at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:821)
04-21 11:42:16.682: E/AndroidRuntime(5642): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:293)
04-21 11:42:16.682: E/AndroidRuntime(5642): at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:505)
04-21 11:42:16.682: E/AndroidRuntime(5642): at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:167)
04-21 11:42:16.682: E/AndroidRuntime(5642): ... 11 more
04-21 11:42:16.682: E/AndroidRuntime(5642): Caused by: libcore.io.ErrnoException: recvfrom failed: ECONNRESET (Connection reset by peer)
04-21 11:42:16.682: E/AndroidRuntime(5642): at libcore.io.Posix.recvfromBytes(Native Method)
04-21 11:42:16.682: E/AndroidRuntime(5642): at libcore.io.Posix.recvfrom(Posix.java:136)
04-21 11:42:16.682: E/AndroidRuntime(5642): at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:164)
04-21 11:42:16.682: E/AndroidRuntime(5642): at libcore.io.IoBridge.recvfrom(IoBridge.java:557)
04-21 11:42:16.682: E/AndroidRuntime(5642): ... 23 more


Hessian使用的是短连接,而android默认开启了http连接池,这样就导致了上面的异常:

因为Hessian在使用完成后close了http连接,在下次复用时就会报这个错误了


解决方法:

System.setProperty("http.keepAlive", "false");

你可能感兴趣的:(Android HessianConnectionException SocketException (Connection reset by)