set the permission yet? On Tue, Jan 22, 2013 at 6:36 PM, a <[email protected]> wrote:
> Hi, I have a HTTP server in Android. When I issue multiple GET requests, > sometimes I am getting an exception like the following: > > 01-22 10:28:22.779: W/System.err(2019): java.net.SocketException: recvfrom > failed: ECONNRESET (Connection reset by peer) > 01-22 10:28:22.779: W/System.err(2019): at > libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:552) > 01-22 10:28:22.779: W/System.err(2019): at > libcore.io.IoBridge.recvfrom(IoBridge.java:516) > 01-22 10:28:22.779: W/System.err(2019): at > java.net.PlainSocketImpl.read(PlainSocketImpl.java:488) > 01-22 10:28:22.779: W/System.err(2019): at > java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46) > 01-22 10:28:22.784: W/System.err(2019): at > java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:240) > 01-22 10:28:22.784: W/System.err(2019): at > org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:103) > 01-22 10:28:22.784: W/System.err(2019): at > org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:191) > 01-22 10:28:22.784: W/System.err(2019): at > org.apache.http.impl.io.HttpRequestParser.parseHead(HttpRequestParser.java:71) > 01-22 10:28:22.784: W/System.err(2019): at > org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:174) > 01-22 10:28:22.784: W/System.err(2019): at > org.apache.http.impl.AbstractHttpServerConnection.receiveRequestHeader(AbstractHttpServerConnection.java:141) > 01-22 10:28:22.784: W/System.err(2019): at > org.apache.http.protocol.HttpService.handleRequest(HttpService.java:135) > 01-22 10:28:22.784: W/System.err(2019): at > com.example.devicecommunication.ConnectService$WorkerThread.run(ConnectService.java:744) > 01-22 10:28:22.784: W/System.err(2019): Caused by: > libcore.io.ErrnoException: recvfrom failed: ECONNRESET (Connection reset by > peer) > 01-22 10:28:22.784: W/System.err(2019): at > libcore.io.Posix.recvfromBytes(Native Method) > 01-22 10:28:22.784: W/System.err(2019): at > libcore.io.Posix.recvfrom(Posix.java:131) > 01-22 10:28:22.784: W/System.err(2019): at > libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:164) > 01-22 10:28:22.789: W/System.err(2019): at > libcore.io.IoBridge.recvfrom(IoBridge.java:513) > 01-22 10:28:22.789: W/System.err(2019): ... 10 more > > > I am not sure why this occurs sometimes as shown below(marked as 1 and 2)- > where I close the DefaultHttpServerConnection and where the handleRequest() > method gets called. I create a new thread for each of the request as in > the link > http://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpServer.java > . > > class WorkerThread extends Thread{ > HttpService httpService; > HttpServerConnection conn; > public WorkerThread(HttpService httpService, HttpServerConnection conn){ > super(); > this.httpService = httpService; > this.conn = conn; > } > public void run(){ > HttpContext context = new BasicHttpContext(null); > try { > Log.d(TAG,"Going to call Handle request here"); > this.httpService.handleRequest(this.conn, context); > ==================================================== 1 > } catch (ConnectionClosedException ex) { > ex.printStackTrace(); > Log.d(TAG,"Client closed connection exception"); > } catch (IOException ex) { > ex.printStackTrace(); > Log.d(TAG,"I/O exceptionnnnn " + ex.getMessage()); > } catch (HttpException ex) { > Log.d(TAG,"Unrecoverable HTTP protocol violation: " + > ex.getMessage()); > } > finally { > Log.d(TAG,"Inside Finally Block"); > try { > this.conn.close(); > ==========================================================================2 > Log.d(TAG,"Connection closed successfully"); > } catch (IOException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > } > } > } > > Please let me any clue of why this exception occurs. > > Thanks! > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- Regards, Michael Leung http://www.itblogs.info - My IT Blog http://diary.skynovel.info - My Blog http://www.michaelleung.info - My Homepage -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

