Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 701DE4CA1 for ; Thu, 19 May 2011 16:09:54 +0000 (UTC) Received: (qmail 54486 invoked by uid 500); 19 May 2011 16:09:51 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 54312 invoked by uid 500); 19 May 2011 16:09:51 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 54303 invoked by uid 99); 19 May 2011 16:09:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 May 2011 16:09:51 +0000 X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RFC_ABUSE_POST,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of rob_gar_esp@hotmail.com designates 65.55.90.103 as permitted sender) Received: from [65.55.90.103] (HELO snt0-omc2-s28.snt0.hotmail.com) (65.55.90.103) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 May 2011 16:09:42 +0000 Received: from SNT128-W15 ([65.55.90.72]) by snt0-omc2-s28.snt0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 19 May 2011 09:09:21 -0700 Message-ID: X-Originating-IP: [80.36.134.143] From: Rob GB To: Subject: RE: Tomcat download stream gets broken Date: Thu, 19 May 2011 11:09:20 -0500 Importance: Normal In-Reply-To: <4DD53F5B.9040805@ice-sa.com> References: ,<4DD527A1.10605@pidster.com> ,<4DD53F5B.9040805@ice-sa.com> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginalArrivalTime: 19 May 2011 16:09:21.0473 (UTC) FILETIME=[1D26BB10:01CC163F] X-Virus-Checked: Checked by ClamAV on apache.org Hi=2CI sent it from gmail in the right format some minutes ago=2C you shoul= d had already received it.Here it goes again.=A0Thanks. =A0 =A0 public void service(HttpServletRequest request=2C HttpServletRespon= se response) throws IOException {=A0 =A0 =A0 =A0 byte buf[] =3D new byte[10= 24 * 4]=3B=A0 =A0 =A0 =A0 try {=A0 =A0 =A0 =A0 =A0 =A0 File file =3D new Fi= le(realFilename)=3B=A0 =A0 =A0 =A0 =A0 =A0 int size =3D (int) file.length()= =3B=A0 =A0 =A0 =A0 =A0 =A0 BufferedInputStream realFile =3D new BufferedInp= utStream(new FileInputStream(file))=3B=A0 =A0 =A0 =A0 =A0 =A0 OutputStream = out =3D response.getOutputStream()=3B=A0 =A0 =A0 =A0 =A0 =A0 response.setCo= ntentLength(size)=3B=A0 =A0 =A0 =A0 =A0 =A0 while (true) {=A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 int count =3D realFile.read(buf)=3B=A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 if (count =3D=3D -1) {=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break= =3B=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 out.wri= te(buf=2C 0=2C count)=3B=A0 =A0 =A0 =A0 =A0 =A0 }=A0 =A0 =A0 =A0 =A0 =A0 ou= t.flush()=3B=A0 =A0 =A0 =A0 } catch (FileNotFoundException e) {=A0 =A0 =A0 = =A0 =A0 =A0 logger.error("Stream download failed=2C file not found: " + rea= lFilename=2C e)=3B=A0 =A0 =A0 =A0 =A0 =A0 response.sendError(404)=3B=A0 =A0= =A0 =A0 } catch (Exception e) {=A0 =A0 =A0 =A0 =A0 =A0 logger.error("Downl= oadException:"=2C e)=3B=A0 =A0 =A0 =A0 }=A0 =A0 } However once in a while I get an error that prevents files from being downl= oaded: DownloadException: =A0java.net.SocketException: Broken pipe=A0 =A0 =A0 =A0 = at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.j= ava:366)=A0 =A0 =A0 =A0 at org.apache.tomcat.util.buf.ByteChunk.flushBuffer= (ByteChunk.java:432)=A0 =A0 =A0 =A0 at org.apache.tomcat.util.buf.ByteChunk= .append(ByteChunk.java:347)=A0 =A0 =A0 =A0 at org.apache.catalina.connector= .OutputBuffer.writeBytes(OutputBuffer.java:392)=A0 =A0 =A0 =A0 at org.apach= e.catalina.connector.OutputBuffer.write(OutputBuffer.java:381)=A0 =A0 =A0 = =A0 at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputS= tream.java:89)=A0 =A0 =A0 =A0 at javax.servlet.http.HttpServlet.service(Htt= pServlet.java:802)=A0 =A0 =A0 =A0 at org.apache.catalina.core.ApplicationFi= lterChain.internalDoFilter(ApplicationFilterChain.java:269)=A0 =A0 =A0 =A0 = at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt= erChain.java:188)=A0 =A0 =A0 =A0 at org.apache.catalina.core.ApplicationFil= terChain.internalDoFilter(ApplicationFilterChain.java:215)=A0 =A0 =A0 =A0 a= t org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilte= rChain.java:188)=A0 =A0 =A0 =A0 at org.apache.catalina.core.StandardWrapper= Valve.invoke(StandardWrapperValve.java:213)=A0 =A0 =A0 =A0 at org.apache.ca= talina.core.StandardContextValve.invoke(StandardContextValve.java:172)=A0 = =A0 =A0 =A0 at org.apache.catalina.core.StandardHostValve.invoke(StandardHo= stValve.java:127)=A0 =A0 =A0 =A0 at org.apache.catalina.valves.ErrorReportV= alve.invoke(ErrorReportValve.java:117)=A0 =A0 =A0 =A0 at org.apache.catalin= a.core.StandardEngineValve.invoke(StandardEngineValve.java:108)=A0 =A0 =A0 = =A0 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.ja= va:174)=A0 =A0 =A0 =A0 at org.apache.coyote.http11.Http11Processor.process(= Http11Processor.java:875)=A0 =A0 =A0 =A0 at org.apache.coyote.http11.Http11= BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.j= ava:665)=A0 =A0 =A0 =A0 at org.apache.tomcat.util.net.PoolTcpEndpoint.proce= ssSocket(PoolTcpEndpoint.java:528)=A0 =A0 =A0 =A0 at org.apache.tomcat.util= .net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:113)=A0 =A0 = =A0 =A0 at java.lang.Thread.run(Thread.java:619)Caused by: java.net.SocketE= xception: Broken pipe=A0 =A0 =A0 =A0 at java.net.SocketOutputStream.socketW= rite0(Native Method)=A0 =A0 =A0 =A0 at java.net.SocketOutputStream.socketWr= ite(SocketOutputStream.java:92)=A0 =A0 =A0 =A0 at java.net.SocketOutputStre= am.write(SocketOutputStream.java:136)=A0 =A0 =A0 =A0 at org.apache.coyote.h= ttp11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:750)=A0= =A0 =A0 =A0 at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.= java:432)=A0 =A0 =A0 =A0 at org.apache.tomcat.util.buf.ByteChunk.append(Byt= eChunk.java:347)=A0 =A0 =A0 =A0 at org.apache.coyote.http11.InternalOutputB= uffer$OutputStreamOutputBuffer.doWrite(InternalOutputBuffer.java:773)=A0 = =A0 =A0 =A0 at org.apache.coyote.http11.filters.IdentityOutputFilter.doWrit= e(IdentityOutputFilter.java:118)=A0 =A0 =A0 =A0 at org.apache.coyote.http11= .InternalOutputBuffer.doWrite(InternalOutputBuffer.java:583)=A0 =A0 =A0 =A0= at org.apache.coyote.Response.doWrite(Response.java:560)=A0 =A0 =A0 =A0 at= org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.jav= a:361)=A0 =A0 =A0 =A0 ... 23 more > Date: Thu=2C 19 May 2011 18:03:39 +0200 > From: aw@ice-sa.com > To: users@tomcat.apache.org > Subject: Re: Tomcat download stream gets broken >=20 > Rob GB wrote: > >> No-one is going to read all that unformatted code. Try again.> > p>=20 > > ok=2C trying again=2C it looks formatted in hotmail editor: >=20 > Get a better email program=2C cause it ain't formatted here. > Are you trying to send this "as html" by any chance ? If yes=2C then try = "as plain text" if=20 > your email program has such an option. >=20 > --------------------------------------------------------------------- > To unsubscribe=2C e-mail: users-unsubscribe@tomcat.apache.org > For additional commands=2C e-mail: users-help@tomcat.apache.org >=20 = --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org