Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
6.1k views
in Java FTP by (200 points)
Hello,


I am trying to do an upload using edtftp-2.1.0. My code works on most of the servers but when i connect to a specific server the dataconnection is closed. When using othe ftp client the server responds correctly. I tried active and passive mode.

Anybody knows what is causing this. Firewalls should be ok as filezilla can connect with it.

My code:

FileTransferClient ftc;
ftc = new FileTransferClient();
ftc.setEventListener(new Listener());
      ftc.setRemoteHost("<hostname>");
      ftc.setRemotePort( 21 );
      ftc.setUserName("user");
      ftc.setPassword("pass");
      ftc.setContentType(FTPTransferType.BINARY);
      
      ftc.getAdvancedFTPSettings().setConnectMode(FTPConnectMode.PASV);
      ftc.connect();
      ftc.uploadFile("c:/temp/dummy.mxf","/OCBACI02001/toPolopoly/fromArdome/dummy.mxf",WriteMode.OVERWRITE);


Output:

IWAV0055I Java Bean test started with the main method
reply received 220 Connection ok (10.220.65.186:4438)
cmd send: ---> USER vtrsync
reply received 331 User ok, need password
cmd send: ---> PASS ********
reply received 230 User logged in
cmd send: ---> TYPE I
reply received 200 Type is I
cmd send: ---> PWD
reply received 257 "i:"
cmd send: ---> PASV
reply received 227 Entering Passive Mode (10,240,45,165,17,235)
cmd send: ---> STOR /OCBACI02001/toPolopoly/fromArdome/dummy.mxf
reply received 125 Dataconnection already open, starting
Bytes: 65536
reply received 426 Connection closed; transfer aborted
cmd send: ---> SIZE /OCBACI02001/toPolopoly/fromArdome/dummy.mxf
reply received 500 File not found
cmd send: ---> PASV
reply received 227 Entering Passive Mode (10,240,45,165,17,236)
cmd send: ---> REST 0
reply received 500 Command not recognised
com.enterprisedt.net.ftp.FTPException: 500 Command not recognised
at com.enterprisedt.net.ftp.FTPControlSocket.validateReply(FTPControlSocket.java:1216)
at com.enterprisedt.net.ftp.FTPClient.restart(FTPClient.java:2190)
at com.enterprisedt.net.ftp.FTPClient.initPut(FTPClient.java:2643)
at com.enterprisedt.net.ftp.FTPClient.putData(FTPClient.java:2712)
at com.enterprisedt.net.ftp.FTPClient.putStream(FTPClient.java:2451)
at com.enterprisedt.net.ftp.FTPClient.put(FTPClient.java:2419)
at com.enterprisedt.net.ftp.FileTransferClient.uploadFile(FileTransferClient.java:802)
at test.main(test.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at org.eclipse.ve.internal.java.vce.launcher.remotevm.JavaBeansLauncher.main(JavaBeansLauncher.java:79)
cmd send: ---> STOR /OCBACI02001/toPolopoly/fromArdome/dummy.mxf
reply received 125 Dataconnection already open, starting
Bytes: 65536
reply received 426 Connection closed; transfer aborted
cmd send: ---> SIZE /OCBACI02001/toPolopoly/fromArdome/dummy.mxf
reply received 500 File not found

4 Answers

0 votes
by (162k points)
It is possible that this is a firewall problem. Can Filezilla send a file from the same machine? Please post the Filezilla log.
0 votes
by (200 points)
Thank you for the reply. Filezilla isn't installed at the other machine. I tried the ftp cmd client at that machine and indeed the dataconnection is blocked. So I send a request to open the firewalls.


I should have known this myself. I tried to open a ftp connection from the client machine to the server but didn't try uploading a file :oops: . From the dev machine I tried uploading one and that one succeeded.
0 votes
by (200 points)
It wasn't the firewall. I had 2 problems:

One a REST 0 was send which isn't supported by the server. So i changed FTPClient.restart into:

   public String put(String localPath, String remoteFile, boolean append)
        throws IOException, FTPException {
                   
        String cwd = safePwd();
        remoteFile=cwd+remoteFile;
        FTPTransferType previousType = transferType;
        FTPTransferType currentTransferType = chooseTransferMode(remoteFile);
...


Is this correct or am I using your library wrong ?
0 votes
by (162k points)
Ok, that's unusual that REST isn't supported.

We might make a change there. Thanks for the info.

Categories

...