Thanks for the lead guys. Looks like something is there could be the window=
s firewall.
Both tomcat and browser are on the same machine. Tried accessing the servic=
e using localhost=2C got the exception.
Tried using IP address=2C no exception :(.
Any trick using which I can get this exception reliably? I am already using=
the header Pragma: no-cache.
=20
> Date: Thu=2C 4 Aug 2011 14:01:16 -0400
> From: dckerber@verizon.net
> To: users@tomcat.apache.org
> Subject: Re: Who ate my "Connection reset by peer" SocketException?
>=20
> On 8/4/2011 1:38 PM=2C Debashis Roy wrote:
> >
> > Nothing in between browser and tomcat... direct connection from IE to 8=
080.
>=20
> Not even a router? What about the windows firewall?
>=20
>=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?
> >>
> >> Debashis Roy wrote:
> >>> Hi=2C
> >>>
> >>> Trying something which involves catching the "Connection reset by pee=
r" SocketException. Below is the code snippet from my servlet with explanat=
ory comments.
> >>> Does anyone have any idea as to what is happening?
> >>>
> >>> try
> >>> {
> >>> byte [] bytes =3D getContentBytes()=3B //read the actual bytes of the=
content into an array.
> >>> resp.addHeader("Content-Disposition"=2C "attachment=3Bfilename=3Dsome=
file.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 to=
mcat 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 sa=
ve 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
> >>>
> >>> /* Voila !!! no exceptions till here and the code exits cleanly !!! *=
/
> >>> }
> >>> catch (Throwable th)
> >>> {
> >>> th.printStackTrace()=3B
> >>> }
> >>>
> >>
> >> Is there anything at all between the browser and Tomcat ?
> >> (thinking of a front-end webserver/load balancer etc..)
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe=2C e-mail: users-unsubscribe@tomcat.apache.org
> >> For additional commands=2C e-mail: users-help@tomcat.apache.org
> >>
> >=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
=
|