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 0101B621D for ; Thu, 4 Aug 2011 17:38:59 +0000 (UTC) Received: (qmail 76981 invoked by uid 500); 4 Aug 2011 17:38:53 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 76346 invoked by uid 500); 4 Aug 2011 17:38: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 76335 invoked by uid 99); 4 Aug 2011 17:38:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Aug 2011 17:38:51 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of r_debashis@hotmail.com designates 65.54.190.77 as permitted sender) Received: from [65.54.190.77] (HELO bay0-omc2-s2.bay0.hotmail.com) (65.54.190.77) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Aug 2011 17:38:42 +0000 Received: from BAY160-W23 ([65.54.190.125]) by bay0-omc2-s2.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 4 Aug 2011 10:38:20 -0700 Message-ID: Content-Type: multipart/alternative; boundary="_7cf08b78-c8a9-48c6-94f7-e5b246b33fe9_" X-Originating-IP: [122.179.92.191] From: Debashis Roy To: Subject: RE: Who ate my "Connection reset by peer" SocketException? Date: Thu, 4 Aug 2011 17:38:20 +0000 Importance: Normal In-Reply-To: <4E3AC6AE.2050503@ice-sa.com> References: ,<4E3AC6AE.2050503@ice-sa.com> MIME-Version: 1.0 X-OriginalArrivalTime: 04 Aug 2011 17:38:20.0986 (UTC) FILETIME=[4D8E81A0:01CC52CD] X-Virus-Checked: Checked by ClamAV on apache.org --_7cf08b78-c8a9-48c6-94f7-e5b246b33fe9_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Nothing in between browser and tomcat... direct connection from IE to 8080. =20 > Date: Thu=2C 4 Aug 2011 18:19:58 +0200 > From: aw@ice-sa.com > To: users@tomcat.apache.org > Subject: Re: Who ate my "Connection reset by peer" SocketException? >=20 > Debashis Roy wrote: > > Hi=2C > >=20 > > Trying something which involves catching the "Connection reset by peer"= SocketException. Below is the code snippet from my servlet with explanator= y comments. > > Does anyone have any idea as to what is happening? > >=20 > > try > > { > > byte [] bytes =3D getContentBytes()=3B //read the actual bytes of the c= ontent into an array. > > resp.addHeader("Content-Disposition"=2C "attachment=3Bfilename=3Dsomefi= le.zip")=3B > > resp.addHeader("Content-Type"=2C "application/zip")=3B > > resp.addHeader("Pragma"=2C "no-cache")=3B > > resp.addHeader("Connection"=2C "close")=3B > > resp.setContentLength(bytes.length)=3B > > OutputStream os =3D resp.getOutputStream()=3B > > for (int i =3D 0=3B i < bytes.length=3B i++) > > { > > System.out.println("writing byte " + i)=3B > > os.write(bytes[i])=3B > > /* write all bytes but the last one to the ostream */ > > /* the file save dialog shows up in the browser */ > > /* netstat shows an established connection from browser to 8080 of tomc= at host */ > > if (i =3D=3D bytes.length - 2) > > { > > System.out.println("doing intermediate flush...")=3B > > resp.flushBuffer()=3B > > /* sleep for 30 secs */ > > /* during this time close the browser and click cancel on the file save= dialog*/ > > /* netstat shows zero connections with port 8080 of tomcat */ > > try > > { > > Thread.sleep(30000)=3B > > } > > catch (InterruptedException interex) > > { > > } > > } > > /* the last byte gets written after the sleep period */ > > /* was expecting to see the "connection reset by peer" exception here *= / > > } > > /* or here */ > > resp.flushBuffer()=3B > >=20 > > /* Voila !!! no exceptions till here and the code exits cleanly !!! */ > > } > > catch (Throwable th) > > { > > th.printStackTrace()=3B > > } > >=20 >=20 > Is there anything at all between the browser and Tomcat ? > (thinking of a front-end webserver/load balancer etc..) >=20 >=20 >=20 > --------------------------------------------------------------------- > To unsubscribe=2C e-mail: users-unsubscribe@tomcat.apache.org > For additional commands=2C e-mail: users-help@tomcat.apache.org >=20 = --_7cf08b78-c8a9-48c6-94f7-e5b246b33fe9_--