Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
5.9k views
in Java FTP by (162k points)
From a user:

Hello,

I'm writing ftp client in JDK 1.5 and I have a problem, I'm getting these errors:
on upload:
FTP Error: vas.VASFileTransferException: Wystapil FTPException: com.enterprisedt
.net.ftp.FTPException: Illegal PORT command and FileTransferException on download, my code is here:

    private void connect(String serverName, int portNumber)
    throws FTPException, IOException{
        this.ftpClient = new FTPClient(serverName, portNumber);
        try{
            ftpClient.login(logger.getLogin(),logger.getPassword());
        }
        catch(FTPException exc){
            throw new FTPException("Blad autentykacji");
        }
        ftpClient.setType(FTPTransferType.BINARY);
        ftpClient.setConnectMode(FTPConnectMode.ACTIVE);
        ftpClient.setProgressMonitor(this.progressMonitor);
    }

    public void upload(File f, URL url)
    throws VASFileTransferException{
        String host=url.getHost();
        int port=url.getPort();
        File filePath=new File(url.getPath());
        String directory=filePath.getParent().substring(1);
        String filename=filePath.getName();
        try{
            connect(host, port);
            ftpClient.chdir(directory);
            ftpClient.put(new FileInputStream(f), filename);
            disconnect();
        }
        catch(FTPException exc){
            throw new vas.VASFileTransferException("Wystapil FTPException: "+exc);
        }
        catch(IOException exc){
            throw new vas.VASFileTransferException("Wystapil IOException: "+exc);
        }
    }
    
    public void download(URL url, File destination)
    throws vas.VASFileTransferException{
        String host=url.getHost();
        int port=url.getPort();
        File filePath=new File(url.getPath());
        String directory=filePath.getParent().substring(1);
        String filename=filePath.getName();
        try{
            connect(host, port);
            ftpClient.chdir(directory);
            ftpClient.get(new FileOutputStream(destination), filename);
            disconnect();
        }
        catch(FTPException exc){
            throw new vas.VASFileTransferException();
        }
        catch(IOException exc){
            throw new vas.VASFileTransferException();
        }
    }
}



Have you got any suggestions? This error isn't show on JDK 1.4.2
[/code]

1 Answer

0 votes
by (162k points)
You may be using a proxy. Some FTP servers require that the IP address specified in the PORT command is the same as the client's IP address - which may not be the case when a proxy is used.

One option is to use passive mode transfer.

The other is to force your client's IP address (not hostname) in the PORT command by using the setPORTIP() method.

From a user:

Hello,

I'm writing ftp client in JDK 1.5 and I have a problem, I'm getting these errors:
on upload:
FTP Error: vas.VASFileTransferException: Wystapil FTPException: com.enterprisedt
.net.ftp.FTPException: Illegal PORT command and FileTransferException on download,

Categories

...