Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

ClientAbortException: java.net.SocketException: Software caused connection abort:socket write error  RSS feed

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 (DownlaoderServlet.java:77) - fie size 1737743
INFO 07 Jan 2009 13:20:03,593 (DownlaoderServlet.java:87) - error in writing file on stream
ClientAbortException: java.net.SocketException: Software caused connection abort: socket write error
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:366)
at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:403)
at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:323)
at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:392)
at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:381)
at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:76)
at java.util.zip.DeflaterOutputStream.deflate(DeflaterOutputStream.java:156)
at java.util.zip.DeflaterOutputStream.write(DeflaterOutputStream.java:114)
at java.util.zip.GZIPOutputStream.write(GZIPOutputStream.java:72)
at java.io.FilterOutputStream.write(FilterOutputStream.java:80)
at com.tcm.autumn.servlets.DownlaoderServlet.doGet(DownlaoderServlet.java:81)
at com.tcm.autumn.servlets.DownlaoderServlet.doPost(DownlaoderServlet.java:110)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)




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.


try{
…………………………
byte[] fileInArray = null;
fileInArray = readFileByte(fileUrl);
OutputStream outStream = new GZIPOutputStream(response.getOutputStream());
output.write(fileInArray); // got exception here
……………………………
outStream.flush();
outStream.close();
}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];
fileInputStream.read(contentByte);

fileInputStream.close();
return contentByte;
}
 
Bartender
Posts: 9507
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One thing you should be aware of is ReadDoesntDoWhatYouThinkItDoes
I'll bet your read terminates before all the data is sent.
 
Muhammad Arif
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have changed the read method. but still that exception. File is fully read but while writing it on stream exception occer. I have print the file size in logger. that is actual size of file. this will happen when file size is greater then or equal to 2 MB


{
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
File aFile = new File(filePath);
InputStream is = new FileInputStream(aFile);
byte[] temp = new byte[1024];
int read;

while((read = is.read(temp)) > 0){
buffer.write(temp, 0, read);
}

byte[] data = buffer.toByteArray();

return data;
}






INFO 07 Jan 2009 20:50:19,156 (DownlaodManager.java:105) - Url for file is D:/arif/download-data/img/bowlinehearder.bmp
INFO 07 Jan 2009 20:50:19,156 (DownlaoderServlet.java:62) - fileUrl D:/arif/download-data/img/bowlinehearder.bmp
INFO 07 Jan 2009 20:50:19,453 (DownlaoderServlet.java:79) - fie size 2880054
INFO 07 Jan 2009 20:50:19,531 (DownlaoderServlet.java:89) - error in writing file on stream
ClientAbortException: java.net.SocketException: Software caused connection abort: socket write error
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:366)
at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:403)
at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:323)




 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!