?
Solved

SocketException: Software caused connection abort

Posted on 2007-03-23
15
Medium Priority
?
1,624 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 7
15 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 2000 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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This video teaches viewers about errors in exception handling.
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…
Suggested Courses
Course of the Month11 days, 4 hours left to enroll

770 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