Solved

SocketException: Software caused connection abort

Posted on 2007-03-23
15
1,611 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
 

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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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:mayankeagle
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Creating an OSPF network that automatically (dynamically) reroutes network traffic over other connections to prevent network downtime.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to implement Singleton Design Pattern in Java.

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now