tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David kerber <dcker...@verizon.net>
Subject Re: Who ate my "Connection reset by peer" SocketException?
Date Thu, 04 Aug 2011 18:01:16 GMT
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
View raw message