This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Servlets and the fly likes ClientAbortException: Software caused connection abort:socket write error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "ClientAbortException: Software caused connection abort:socket write error" Watch "ClientAbortException: Software caused connection abort:socket write error" New topic

ClientAbortException: Software caused connection abort:socket write error

Muhammad Arif

Joined: Jan 07, 2009
Posts: 5
I have problem while sending the data on mobile client. This is happing when I sending file(audio, image or video) of size 2 or more MB.
The exact exception is here

INFO 07 Jan 2009 13:20:03,562 ( - fie size 1737743
INFO 07 Jan 2009 13:20:03,593 ( - error in writing file on stream
ClientAbortException: Software caused connection abort: socket write error
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(
at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(
at org.apache.tomcat.util.buf.ByteChunk.append(
at org.apache.catalina.connector.OutputBuffer.writeBytes(
at org.apache.catalina.connector.OutputBuffer.write(
at org.apache.catalina.connector.CoyoteOutputStream.write(
at com.tcm.autumn.servlets.DownlaoderServlet.doGet(
at com.tcm.autumn.servlets.DownlaoderServlet.doPost(
at javax.servlet.http.HttpServlet.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.apache.catalina.core.ApplicationDispatcher.invoke(

if file size is less then the 2MB then file send successfully. Sir can you help me in this type of error. File reading and sending code is here.

byte[] fileInArray = null;
fileInArray = readFileByte(fileUrl);
OutputStream outStream = new GZIPOutputStream(response.getOutputStream());
output.write(fileInArray); // got exception here
}catch(Exception e){


public static byte[] readFileByte(String filePath) throws FileNotFoundException, IOException
FileInputStream fileInputStream = null;
byte[] contentByte = null;
File contentFile = new File(filePath);
int contentSize = (int) contentFile.length();
fileInputStream = new FileInputStream(contentFile);

contentByte = new byte[contentSize];;

return contentByte;
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

You are better off reading a part from the source and writing to the destination repeatedly, rather than trying to read the source first.
It is a bit hard to tell, since your try/catch hides any exceptions.
Muhammad Arif

Joined: Jan 07, 2009
Posts: 5
but the problem is that application is not able to send file more then 2 MB file
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: ClientAbortException: Software caused connection abort:socket write error
It's not a secret anymore!