On 20.03.19 12:08, Saurav Sarkar wrote:
> Just to add the stack trace.
> 
> I am getting ClientAbortException "Connection reset by peer" when i am
> trying to write to the response stream
> 
> 2019-03-20T10:32:28.501+0000 [APP/PROC/WEB/0] ERR
> org.apache.catalina.connector.ClientAbortException: java.io.IOException:
> Connection reset by peer
> 2019-03-20T10:32:28.502+0000 [APP/PROC/WEB/0] ERR at
> org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:364)
...

> 
> On Wed, Mar 20, 2019 at 3:51 PM Saurav Sarkar <saurav.sark...@gmail.com>
> wrote:
> 
>> Hi All
>>
>> I have a very basic test application which serves bytes from memory and
>> gives it back to the client.
>>
>> Whenever i try to send the request for byte size which is of over 2 GB i
>> get a connection reset error in my server code and a 502 error in my chrome
>> console. Below 2 GB it is working fine.
>>
>> In my client side i execute java script which i execute from the browser.
>> This basically executes an XMLHTTPRequest , gets the response (stores in
>> browser memory) and asks for a save.
>>
>> I would like to know if there Is there max response size default value
>> which is set in default tomcat configuration. ? or any other hints which
>> you can provide in my use.
>>
>>
>> Thanks and Regards,
>>
>> Saurav
>>
>> Below is the servlet or server side code
>>
>>
>>
>>         response.setContentLength((int)length);
>>
>>       }
>>
>>       else
>>
>>       {
>>
>>         response.addHeader("Content-Length", Long.toString(length));
>>
>>       }

You don't include the initial condition in your code, but I'm assuming
that the first line is hit: response.setContentLength((int)length);

int in Java is defined to be 32 bit, and always signed. That means that
any value larger than 2^31 or Integer.MAX_VALUE can't be expressed in
int as a positive number. In fact, anything between 2^31 and 2^32 will
be interpreted as a negative number, so you're effectively setting the
content length to be negative.

Note that there's also a setContentLengthLong method
https://docs.oracle.com/javaee/7/api/javax/servlet/ServletResponse.html#setContentLengthLong-long-



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to