Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this questionI am running a ftp server using filezilla in windows. I am able to connect to it, but when I try to upload a file or list the files, I get an exception. I was trying the example from this page http://www.kodejava.org/examples/357.html
Login success...
java.net.SocketException: Software caused connection abort: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:291)
at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:295)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)
at java.io.BufferedWriter.flush(BufferedWriter.java:254)
at org.apache.commons.net.ftp.FTP.__send(FTP.java:496)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:470)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:547)
at org.apache.commons.net.ftp.FTP.port(FTP.java:872)
at org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:667)
at org.apache.commons.net.ftp.FTPClient.listNames(FTPClient.java:2528)
at org.apache.commons.net.ftp.FTPClient.listNames(FTPClient.java:2574)
On the server logs I see the following
(000032)9/16/2011 14:38:28 PM - (not logged in) (127.0.0.1)> Connected, sending welcome message...
(000032开发者_运维问答)9/16/2011 14:38:28 PM - (not logged in) (127.0.0.1)> 220-FileZilla Server version 0.9.39 beta
(000032)9/16/2011 14:38:28 PM - (not logged in) (127.0.0.1)> 220-written by Tim Kosse (Tim.Kosse@gmx.de)
(000032)9/16/2011 14:38:28 PM - (not logged in) (127.0.0.1)> 220 Please visit http://sourceforge.net/projects/filezilla/
(000032)9/16/2011 14:38:28 PM - (not logged in) (127.0.0.1)> USER reverb0253
(000032)9/16/2011 14:38:28 PM - (not logged in) (127.0.0.1)> 331 Password required for reverb0253
(000032)9/16/2011 14:38:28 PM - (not logged in) (127.0.0.1)> PASS ********
(000032)9/16/2011 14:38:28 PM - reverb0253 (127.0.0.1)> 230 Logged on
(000032)9/16/2011 14:38:40 PM - reverb0253 (127.0.0.1)> disconnected.
Right when I hits the like client.storeFile(), the server logs disconnected. I am using apache commons-net 3.0.1
FTP opens another connection when you do a directory listing or file transfer. It is possible the connection is blocked by a firewall or security software. This is known as the "data channel" and the exact port is negotiated during the session. I would expect to see either a PORT or PASV in the server log immdiately before the data channel is opened. You might have to use wireshark on the client side to see exactly what you are sending.
精彩评论