tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Debashis Roy <r_debas...@hotmail.com>
Subject RE: Who ate my "Connection reset by peer" SocketException?
Date Fri, 05 Aug 2011 04:50:02 GMT

Thanks for the lead guys. Looks like something is there could be the windows firewall.
Both tomcat and browser are on the same machine. Tried accessing the service using localhost,
got the exception.
Tried using IP address, no exception :(.
Any trick using which I can get this exception reliably? I am already using the header Pragma:
no-cache.

 

> Date: Thu, 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?
> 
> On 8/4/2011 1:38 PM, Debashis Roy wrote:
> >
> > Nothing in between browser and tomcat... direct connection from IE to 8080.
> 
> Not even a router? What about the windows firewall?
> 
> 
> >
> >
> >> Date: Thu, 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,
> >>>
> >>> Trying something which involves catching the "Connection reset by peer"
SocketException. Below is the code snippet from my servlet with explanatory comments.
> >>> Does anyone have any idea as to what is happening?
> >>>
> >>> try
> >>> {
> >>> byte [] bytes = getContentBytes(); //read the actual bytes of the content
into an array.
> >>> resp.addHeader("Content-Disposition", "attachment;filename=somefile.zip");
> >>> resp.addHeader("Content-Type", "application/zip");
> >>> resp.addHeader("Pragma", "no-cache");
> >>> resp.addHeader("Connection", "close");
> >>> resp.setContentLength(bytes.length);
> >>> OutputStream os = resp.getOutputStream();
> >>> for (int i = 0; i< bytes.length; i++)
> >>> {
> >>> System.out.println("writing byte " + i);
> >>> os.write(bytes[i]);
> >>> /* 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 tomcat
host */
> >>> if (i == bytes.length - 2)
> >>> {
> >>> System.out.println("doing intermediate flush...");
> >>> resp.flushBuffer();
> >>> /* 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);
> >>> }
> >>> 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();
> >>>
> >>> /* Voila !!! no exceptions till here and the code exits cleanly !!! */
> >>> }
> >>> catch (Throwable th)
> >>> {
> >>> th.printStackTrace();
> >>> }
> >>>
> >>
> >> Is there anything at all between the browser and Tomcat ?
> >> (thinking of a front-end webserver/load balancer etc..)
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >>
> > 
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
 		 	   		  
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message