You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Adriana Suarez <ad...@gmail.com> on 2005/06/28 05:32:56 UTC

ClientAbortException: java.net.SocketException: Connection reset by peer: socket write error

Hello,

I got this exception and I don't know how to solve it, I have a web
application with a servlet which sends video with formats avi, mpeg,
and mov, it shows the video but the tomcat throws this exception:

ClientAbortException:  java.net.SocketException: Connection reset by
peer: socket write error
	at org.apache.coyote.tomcat5.OutputBuffer.realWriteBytes(OutputBuffer.java:373)
	at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:323)
	at org.apache.coyote.tomcat5.OutputBuffer.writeBytes(OutputBuffer.java:401)
	at org.apache.coyote.tomcat5.OutputBuffer.write(OutputBuffer.java:388)
	at org.apache.coyote.tomcat5.CoyoteOutputStream.write(CoyoteOutputStream.java:76)
	at java.io.BufferedOutputStream.write(BufferedOutputStream.java:106)
	at helloworldservlet.ServletVideo.streamBinaryData(ServletVideo.java:71)
	at helloworldservlet.ServletVideo.doGet(ServletVideo.java:37)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
	at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
	at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
	at java.lang.Thread.run(Thread.java:534)

and this is where the code fails:

 private void streamBinaryData(String urlstr,String
format,ServletOutputStream outstr, HttpServletResponse resp)
  {
        String ErrorStr = null;
        try{
          //find the right mime type and set it as contenttype
          resp.setContentType(getMimeType(format));
          BufferedInputStream bis = null;
          BufferedOutputStream bos = null;
          try{
              URL url	= new URL(urlstr);
              URLConnection urlc= url.openConnection();
              int length =urlc.getContentLength();
              resp.setContentLength(length);
              // Use Buffered Stream for reading/writing.
              InputStream in = urlc.getInputStream();
              bis = new BufferedInputStream(in);
              bos = new BufferedOutputStream(outstr);
              byte[] buff = new byte[length];
              int bytesRead;
              // Simple read/write loop.
              while(-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
                bos.write(buff, 0, bytesRead);
              }
          } catch (Exception e) {
                e.printStackTrace();
                ErrorStr = "Error Streaming the Data";
                outstr.print(ErrorStr);
          } finally {
                if( bis != null ) {
                  bis.close();
                }
                if( bos != null ) {
                  bos.close();
                }
                if( outstr != null ) {
                  outstr.flush();
                  outstr.close();
                }
          }
        }
        catch(Exception e){
                e.printStackTrace();
        }
  }

I have read many forums but they do not explain in detail what the
problem is, some they say is a tomcat bug. Can anyone help me to
figure it out?

Thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: ClientAbortException: java.net.SocketException: Connection reset by peer: socket write error

Posted by Tim Funk <fu...@joedog.org>.
Connection reset by peer means the client disconnected before all the data 
was sent.

-Tim


Adriana Suarez wrote:
> Hello,
> 
> I got this exception and I don't know how to solve it, I have a web
> application with a servlet which sends video with formats avi, mpeg,
> and mov, it shows the video but the tomcat throws this exception:
> 
> ClientAbortException:  java.net.SocketException: Connection reset by
> peer: socket write error
> 	at org.apache.coyote.tomcat5.OutputBuffer.realWriteBytes(OutputBuffer.java:373)

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org