• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1631
  • Last Modified:

SocketException: Software caused connection abort

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
tjgquicken
Asked:
tjgquicken
  • 7
  • 7
1 Solution
 
TimYatesCommented:
That's the server closing the socket...

What is it you're sending the data to?
0
 
TimYatesCommented:
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
 
tjgquickenAuthor Commented:
It's a web server, and we're trying to send files to the server via FTP.
0
Independent Software Vendors: 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!

 
tjgquickenAuthor Commented:
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
 
TimYatesCommented:
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
 
tjgquickenAuthor Commented:
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
 
TimYatesCommented:
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
 
tjgquickenAuthor Commented:
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
 
tjgquickenAuthor Commented:
Actually, it's an applet, not a stand-alone application, in case that matters.
0
 
TimYatesCommented:
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
 
tjgquickenAuthor Commented:
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
 
TimYatesCommented:
Has anything changed between now and then?  Does it work again if you restart the webserver for example?  Has anyone installed something new?
0
 
tjgquickenAuthor Commented:
Our hosting company turned the server off and then back on again, and it looks like it's working. Thanks.
0
 
TimYatesCommented:
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
 
Mayank SAssociate Director - Product EngineeringCommented:
>> 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 7
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now