Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
12k views
in Java FTP by (240 points)
I am uisng EDTFtpj and I can not establish connection to remote host.

If I use ftp from command prompt I have to do following
  1. I type ftp
  2. Remote host answers with prompt ftp>
  3. I type open name_of_host port
  4. Remote host answer with prompt username> and I put user name and password and connection
    is established.

If I try from command prompt open connection in following way

ftp name_of_host port

remote host refuse connection.

However, when I use EDTFtpj in following way
try {
  noviObje = new com.enterprisedt.net.ftp.FileTransferClient();
  noviObje.setRemoteHost("200.200.200.123");
  noviObje.setRemotePort(10021); 
  noviObje.getAdvancedFTPSettings().setAutoLogin(false); 
  noviObje.connect();
  noviObje.setUserName("user_name_a");
  noviObje.setPassword("password_a");
  noviObje.setContentType(com.enterprisedt.net.ftp.FTPTransferType.BINARY);
  noviObje.getAdvancedFTPSettings().setConnectMode(com.enterprisedt.net.ftp.FTPConnectMode.ACTIVE);
        
  noviObje.manualLogin();

I can not estblish connection.

Please, help me.

Thank you.

7 Answers

0 votes
by (162k points)
Get rid of autologin flag and set the username & password before connecting. If it still fails, post a log file (see the help).
0 votes
by (240 points)
Thank you for your suggestions, but it stil falls.
I find out that ftp server I connect to is not 'regular' ftp server but some kind of emulation of ftp server.
Actually that ftp server is Connect:Enterprise UNIX 2.4.02. It enables following 'emulation' of ftp server:
active ftp, passive ftp and secure ftp.
I'll send you log file when I get it.
Best regards
0 votes
by (162k points)
We've got plenty of customers who use Connect:Enterprise UNIX so we should be able to get it going.
0 votes
by (240 points)
Finally,
I successfully connected to server, but I can not still
get list of all files on the server.


String myHost = "10.123.5.45";
String myUserName = "BBBAN";
String myPass = "xxxxxxxxxx";
int myPort = 10021;
try {

fTClient.setRemoteHost(myHost);
fTClient.setUserName(myUserName);
fTClient.setPassword(myPass);
fTClient.setRemotePort(myPort) ;

log.info("Connecting to server " + myHost);
log.info("Connecting to server " + myUserName);
log.info("Connecting to server " + myPass);
log.info("Connecting to server " + myPort);

fTClient.connect();
System.out.println ( "Now is connected ");

int mySize = fTClient.directoryNameList().length;
String [] myPolje ;
myPolje = fTClient.directoryNameList();
System.out.println("Length of the list is " + mySize);

for( int i = 0; i< mySize; i++){
System.out.println("File is " + myPolje[i]);
}


fTClient.disconnect();
System.out.println ( "Now is disconnected ");
}catch(com.enterprisedt.net.ftp.FTPException e){

System.out.println( " ERROR " + e.getReplyCode() );

}catch(java.io.IOException eio){

eio.printStackTrace();

}



Result of executing code above is:

INFO [JoJo] 4 lip 2008 12:23:40.546 : Connecting to server 10.123.5.45
INFO [JoJo] 4 lip 2008 12:23:40.546 : Connecting to server BBBAN
INFO [JoJo] 4 lip 2008 12:23:40.546 : Connecting to server xxxxxxxxxx
INFO [JoJo] 4 lip 2008 12:23:40.546 : Connecting to server 10021
Now is connected
Length of the list is 1
File is <<ACTIVITY LOG>>
Now is disconnected


If I use simple ftp from command prompt I get following:


C:\>ftp
ftp> open 10.123.5.45 10021
Connected to 10.123.5.45.
220 <<<Connect:Enterprise UNIX 2.4.02 Secure FTP>>> at thalia FTP server ready.
Time = 12:24:44
User (10.123.5.45:(none)): BBBAN
331 Password required for BBBAN.
Password:
230 Connect:Enterprise UNIX login ok, access restrictions apply.
ftp> dir
200 PORT command successful.
150 Opening ASCII mode data connection for .
-SR--M------- A BBBAN 9 24734 May 16 17:23 <<ACTIVITY LOG>>
-C--------FTP B BBBAN 4700 125 May 20 17:40 WS_FTP.LOG
-C--E-----FTP B BBBAN 18131 122231 Jun 02 14:17 N1234000.F1.INP309.P7S.ENC
Total number of batches listed: 3
226 Transfer complete.
ftp: 261 bytes received in 0,01Seconds 17,40Kbytes/sec.
ftp>

I can not influence on file permisions.

Best regards
0 votes
by (162k points)
Try using directoryList() rather than directoryNameList(), as that is what the command line client is using.
0 votes
by (240 points)
Thank you very much for your help.
Now everything works fine. :D

Only one warning appears.

WARN [FTPFileFactory] 5 lip 2008 13:07:06.78 : Unknown SYST 'UNKNOWN Type: L8' -
defaulting to Unix parsing

Best regards
0 votes
by (162k points)
You can ignore the warning as long as the listings are being parsed correctly.

Categories

...