Solved

SocketException: Software caused connection abort

Posted on 2007-03-23
15
1,616 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
Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Macbook Sierra OS OpenVPN issue 13 111
type mismatch (Object[] to double[] 4 33
Is there a simpler dropbox system? 10 34
How to know if DNS name is  record A or if is ZONE 2 19
The article explains the protocols and technology which is involved when two computers on different TCP/IP networks communicate with each other. In the diagram, a router is used to segregate two networks. The networks are 192.168.1.0/24 and 192…
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 will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

828 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