Solved

SocketException: Software caused connection abort

Posted on 2007-03-23
15
1,618 Views
Last Modified: 2013-11-29
Does anybody know what I can do about this Java exception:
IOException in copyInputStream
Software caused connection abort: socket write error
java.net.SocketException: Software caused connection abort: socket write error
      at java.net.SocketOutputStream.socketWrite0(Native Method)
      at java.net.SocketOutputStream.socketWrite(Unknown Source)
      at java.net.SocketOutputStream.write(Unknown Source)
      at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
      at java.io.BufferedOutputStream.flush(Unknown Source)
      at java.io.FilterOutputStream.flush(Unknown Source)
      at java.io.BufferedOutputStream.flush(Unknown Source)
      at FTA.copyInputStream(FTA.java:1018)
      at FTA.UploadZipFile(FTA.java:873)
      at FTA.DoUpload(FTA.java:515)
      at FTA$5.run(FTA.java:1163)
      at java.security.AccessController.doPrivileged(Native Method)
      at FTA.run(FTA.java:1159)
      at java.lang.Thread.run(Unknown Source)

How do I stop the software aborting the connection? Thanks.
0
Comment
Question by:tjgquicken
  • 7
  • 7
15 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 500 total points
ID: 18780848
That's the server closing the socket...

What is it you're sending the data to?
0
 
LVL 35

Expert Comment

by:TimYates
ID: 18780869
Or, out of interest:

Are you just sending a pile of data and closing it?  Shouldn't you be reading a response from the server?
0
 

Author Comment

by:tjgquicken
ID: 18780898
It's a web server, and we're trying to send files to the server via FTP.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:tjgquicken
ID: 18780935
No, we're just sending files to the server. We have a BufferedInputStream connected to the file on the local machine and a BufferedOutputStream connected to the server, and this exception is getting thrown in the method that copies whatever's on the InputStream onto the OutputStream in one kilobyte chunks. As you can see, we're getting the exception after we flush the OutputStream, and so far, we're always getting this exception right after we've flushed 40960 bytes of data.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 18780963
Are you using FTP code you have written yourself?  I assume so, as I don't recognise FTA.DoUpload()

Why not use an already written FTP client library which handles all of the connecting and stuff for you, like commons-net?

http://jakarta.apache.org/commons/net/

The javadoc shows you how to use it:

http://jakarta.apache.org/commons/net/apidocs/org/apache/commons/net/ftp/FTPClient.html

Tim
0
 

Author Comment

by:tjgquicken
ID: 18781140
Actually, I'm using the java.net.URL class:
URL u = new URL("ftp://username:password@www.domain.com/" + uploadFileName + ";type=i");
conn = u.openConnection();
I needed the quickest solution possible.
Anyway, I downloaded the commons-net-1.4.1.jar file, but how do I link it into my program?
0
 
LVL 35

Expert Comment

by:TimYates
ID: 18781189
Add it to your classpath

You may need the commons-oro library too (from the same download page you got commons-net

Just using URL won't work, as there is a full protocol with FTP, you can't just send data to it, you have to folow protocol
0
 

Author Comment

by:tjgquicken
ID: 18782015
Adding it to my classpath doesn't work. It will compile but it won't link, and when I run the program I get java.lang.NoClassDefFoundError: org/apache/commons/net/ftp/FTPClient.
0
 

Author Comment

by:tjgquicken
ID: 18782027
Actually, it's an applet, not a stand-alone application, in case that matters.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 18782053
Ahhh...  If it's an applet you would need to add the jars to the webapp and link to them using the codebase attribute on the applet tag...

Not sure they work with Applets though...  Hmmm..  Not sure how to ftp from an applet as it goes...

I'll do some investigation...
0
 

Author Comment

by:tjgquicken
ID: 18782089
I guess I should also point out that what I've been doing, opening a URLConnection to a web server with an FTP protocol has been working until a few hours ago....
0
 
LVL 35

Expert Comment

by:TimYates
ID: 18782160
Has anything changed between now and then?  Does it work again if you restart the webserver for example?  Has anyone installed something new?
0
 

Author Comment

by:tjgquicken
ID: 18782234
Our hosting company turned the server off and then back on again, and it looks like it's working. Thanks.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 18782284
It looks like your way should work (after all my nay-saying) ;-)

http://www.javaworld.com/javaworld/jw-04-2003/jw-0404-ftp.html

I would make sure that after you write anything to the server, that you read any response data out of the InputStream as well (to make sure things aren't getting filled to overflowing with responses)

Tim
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 18784504
>> Our hosting company turned the server off and then back on again, and it looks like it's working

Then Tim's first comment is the answer.
0

Featured Post

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CSV file parsing thru Java 13 39
ejb message driven bean mdb creation steps 2 35
java example issue 5 43
Simple Router Management, Subnets and VLANs e.g. RV0xx 7 73
Network ports are the threads that hold network communication together. They are an essential part of networking that can be easily ignore or misunderstood, my goals is to show those who don't have a strong network foundation how network ports opera…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question