Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
6.8k views
in .NET FTP by (300 points)
From perusing the net, it seems that the error message "Software caused connection abort: socket write error" just means something went wrong. It shows up in other programs than edtFTnet and other protocols besides FTP. The various explanations as to its cause I don't think fit my case. I wrote little test program just to get familiar with edtFTPnet. I can change directories, find out what directory I am in, but as soon as I try to get a directory listing it fails.

-------------------------PROGRAM--------------------------

/*
* [BulkFTP.java]
*
* Summary: Upload a large set of files with FTP avoiding those already uploaded.
*
* Copyright: (c) 2011 Roedy Green, Canadian Mind Products, http://mindprod.com
*
* Licence: This software may be copied and used freely for any purpose but military.
* http://mindprod.com/contact/nonmil.html
*
* Requires: JDK 1.6+
*
* Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/
*
* Version History:
* 1.0 2011-12-03 initial release
*/
package com.mindprod.bulkftp;

import com.enterprisedt.net.ftp.FTPConnectMode;
import com.enterprisedt.net.ftp.FTPException;
import com.enterprisedt.net.ftp.FileTransferClient;

import java.io.IOException;

import static java.lang.System.err;
import static java.lang.System.out;

/**
* Upload a large set of files with FTP avoiding those already uploaded.
*
* @author Roedy Green, Canadian Mind Products
* @version 1.0 2011-12-03 initial releas
* @since 2011-12-03
*/
public class BulkFTP
{
public static void main( String[] args )
{

final String host = "mindprod.com"; // 65.110.21.43
final String username = "roedy.mindprod.com";
final String password = System.getenv( "FTP_PASSWORD" );
final String rootDir = "/com/mindprod/www";

out.println( "logging into " + host + " with username " + username + " and password " + password );

final FileTransferClient ftp = new FileTransferClient();
try
{
ftp.getAdvancedFTPSettings().setConnectMode( FTPConnectMode.ACTIVE );
ftp.getAdvancedFTPSettings().setStrictReturnCodes( false );
ftp.setRemoteHost( host );
ftp.setUserName( username );
ftp.setPassword( password );
ftp.connect();
final String initialDir = ftp.getRemoteDirectory();
out.println( "initial cwd " + initialDir );
ftp.changeDirectory( rootDir );
final String absRootdir = ftp.getRemoteDirectory();
out.println( "abs root dir " + absRootdir );
final String[] descriptions = ftp.directoryNameList(); // <-- dies here
for ( String s : descriptions )
{
out.println( s );
}
ftp.disconnect();
}
catch ( FTPException e )
{
err.println( e.getMessage() + " Unable to proceed" );
e.printStackTrace( err );
System.exit( 1 );
}
catch ( IOException e )
{
err.println( e.getMessage() + " Unable to proceed" );
e.printStackTrace( err );
System.exit( 1 );
}

}
}


-------------------------OUTPUT-----------------------------

Connected to the target VM, address: '127.0.0.1:53145', transport: 'socket'
logging into mindprod.com with username roedy.mindprod.com and password xxxx
initial cwd /com/mindprod/usr/roedy
abs root dir /com/mindprod/www
Software caused connection abort: socket write error Unable to proceed
Disconnected from the target VM, address: '127.0.0.1:53145', transport: 'socket'
com.enterprisedt.net.ftp.ControlChannelIOException: Software caused connection abort: socket write error
at com.enterprisedt.net.ftp.FTPControlSocket.writeCommand(FTPControlSocket.java:1020)
at com.enterprisedt.net.ftp.FTPControlSocket.sendCommand(FTPControlSocket.java:997)
at com.enterprisedt.net.ftp.FTPControlSocket.setDataPort(FTPControlSocket.java:813)
at com.enterprisedt.net.ftp.FTPControlSocket.sendPORTCommand(FTPControlSocket.java:669)
at com.enterprisedt.net.ftp.FTPControlSocket.createDataSocketActive(FTPControlSocket.java:616)
at com.enterprisedt.net.ftp.FTPControlSocket.createDataSocket(FTPControlSocket.java:583)
at com.enterprisedt.net.ftp.FTPClient.setupDataSocket(FTPClient.java:2648)
at com.enterprisedt.net.ftp.FTPClient.dir(FTPClient.java:3664)
at com.enterprisedt.net.ftp.FTPClient.dir(FTPClient.java:3756)
at com.enterprisedt.net.ftp.FileTransferClient.directoryNameList(FileTransferClient.java:622)
at com.enterprisedt.net.ftp.FileTransferClient.directoryNameList(FileTransferClient.java:606)
at com.mindprod.bulkftp.BulkFTP.main(BulkFTP.java:62)

4 Answers

0 votes
by (300 points)
I have been reading up a bit on how FTP works. I suspect what is happening is the control socket is working ok, but it fails as soon as it needs to set up the data socket. This would suggest a firewall problem. My router is not blocking any outgoing connections. I don't know how it could deal with incoming connections on random sockets. My ISP told me not to use PASV. Yet other FTP utilities such as FTP voyager and Netload seem to work fine. With my current understanding, that should be impossible.
0 votes
by (162k points)
This is normally a firewall issue. PORT means the server must connect back to the client, and perhaps this is being blocked.

This could be a client firewall, a firewall in between the client and server, or a server firewall.

Check out the logging in your other clients to see whether PORT or PASV is being used. If you enable logging in edtFTPnet (see the guide) you should be able to quickly see how the commands sent differ. Post them here if you want an opinion.
0 votes
by (300 points)
This is normally a firewall issue. PORT means the server must connect back to the client, and perhaps this is being blocked.

This could be a client firewall, a firewall in between the client and server, or a server firewall.

Check out the logging in your other clients to see whether PORT or PASV is being used. If you enable logging in edtFTPnet (see the guide) you should be able to quickly see how the commands sent differ. Post them here if you want an opinion.


I have determined it is a Windows firewall issue. I turn it off and all works fine. I have been fiddling around trying to persuade Windows to let Java.exe through without success. Part of the confusion is there are 10 java.exes on my machine and Windows calls them all the same name in the firewall. I have been fooling around in advanced options so far without success. How are ordinary humans supposed to use the utility I am writing if they have to crack firewall problems this difficult?

I watched FTP Voyager. It uses port 53940, but limiting edtFTPj to that did not help.

When I read about active and pasv modes, it seemed to me active and firewalls were incompatible.
0 votes
by (300 points)
[quote="roedygr"]From perusing the net, it seems that the error message "Software caused connection abort: socket write error" just means something went wrong. It shows up in other programs than edtFTnet and other protocols besides FTP. The various explanations as to its cause I don't think fit my case. I wrote little test program just to get familiar with edtFTPnet. I can change directories, find out what directory I am in, but as soon as I try to get a directory listing it fails.

oh Joy, oh Rapture...

I have it working now, both in PASV and ACTIVE mode. The trick was compiling with Jet to create a unique *.exe executable. The PASV version worked without needing an exception, and Windows prompted me to allow the ACTIVE version through. Thanks very much your prompt response.

Categories

...