09-11 10:02:34.849: W/System.err(17963): java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
09-11 10:02:34.849: W/System.err(17963): at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:542)
09-11 10:02:34.849: W/System.err(17963): at libcore.io.IoBridge.recvfrom(IoBridge.java:506)
09-11 10:02:34.859: W/System.err(17963): at java.net.PlainSocketImpl.read(PlainSocketImpl.java:488)
09-11 10:02:34.859: W/System.err(17963): at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46)
09-11 10:02:34.859: W/System.err(17963): at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:240)
09-11 10:02:34.859: W/System.err(17963): at java.io.InputStream.read(InputStream.java:163)
09-11 10:02:34.869: W/System.err(17963): at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:142)
09-11 10:02:34.869: W/System.err(17963): at java.io.BufferedInputStream.read(BufferedInputStream.java:227)
09-11 10:02:34.869: W/System.err(17963): at libcore.io.Streams.readAsciiLine(Streams.java:201)
09-11 10:02:34.869: W/System.err(17963): at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:544)
09-11 10:02:34.869: W/System.err(17963): at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:784)
09-11 10:02:34.869: W/System.err(17963): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:274)
09-11 10:02:34.869: W/System.err(17963): at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168)
09-11 10:02:34.869: W/System.err(17963): at com.ucaimalls.util.HttpHelper.getHttpUrlConnData(HttpHelper.java:37)
09-11 10:02:34.869: W/System.err(17963): at com.ucaimalls.util.QueryLocationTask.doInBackground(QueryLocationTask.java:49)
09-11 10:02:34.869: W/System.err(17963): at com.ucaimalls.util.QueryLocationTask.doInBackground(QueryLocationTask.java:1)
09-11 10:02:34.869: W/System.err(17963): at android.os.AsyncTask$2.call(AsyncTask.java:264)
09-11 10:02:34.869: W/System.err(17963): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
09-11 10:02:34.869: W/System.err(17963): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
09-11 10:02:34.869: W/System.err(17963): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
09-11 10:02:34.869: W/System.err(17963): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
09-11 10:02:34.869: W/System.err(17963): at java.lang.Thread.run(Thread.java:856)
09-11 10:02:34.879: W/System.err(17963): Caused by: libcore.io.ErrnoException: recvfrom failed: ECONNRESET (Connection reset by peer)
09-11 10:02:34.889: W/System.err(17963): at libcore.io.Posix.recvfromBytes(Native Method)
09-11 10:02:34.889: W/System.err(17963): at libcore.io.Posix.recvfrom(Posix.java:131)
09-11 10:02:34.889: W/System.err(17963): at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:164)
09-11 10:02:34.889: W/System.err(17963): at libcore.io.IoBridge.recvfrom(IoBridge.java:503)
09-11 10:02:34.889: W/System.err(17963): ... 20 more
在网上找了下答案(老外的回答 啊)
ok, the answer was that it's the server's fault - it had to close the connection after each request .
it might be that android keeps a pool of connections and use the old one or something like that .
anyway , now it works.
EDIT: according to the API of HttpURLConnection , this can be solved on the client side too:
The input and output streams returned by this class are not buffered. Most callers should wrap the returned streams with BufferedInputStream or BufferedOutputStream. Callers that do only bulk reads or writes may omit buffering. When transferring large amounts of data to or from a server, use streams to limit how much data is in memory at once. Unless you need the entire body to be in memory at once, process it as a stream (rather than storing the complete body as a single byte array or string).
To reduce latency, this class may reuse the same underlying Socket for multiple request/response pairs. As a result, HTTP connections may be held open longer than necessary. Calls to disconnect() may return the socket to a pool of connected sockets. This behavior can be disabled by setting the http.keepAlive system property to false before issuing any HTTP requests. The http.maxConnections property may be used to control how many idle connections to each server will be held.
taken from: http//developer.android.com/reference/java/net/HttpURLConnection.html