Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Trying to connect to a ftp server

Participant ,
Dec 13, 2011 Dec 13, 2011

I am able to connect to Cerberus (5.0.0.5) using the web browser or using a CoreFTP client, but I can't connect programatically using org.apache.commons.net.ftp.FTPClient. 

Below is my code (this is actually using the java ftpclient through Coldfusion) :

ftpsClient = CreateObject("java","org.apache.commons.net.ftp.FTPClient").init();
ftpsClient.connect(JavaCast("string","xxx.xxx.xxx.xxx"),21);
connected = ftpsClient.isConnected();

login = ftpsClient.login(JavaCast("string","username"),JavaCast("string","password"));

This is what I see in the ftp server log file:

2011/12/13 13:47:54  [0]  Client connected to Cerberus FTP Server 5.0.0.5 on 'machine'

2011/12/13 13:48:41  [1]  Incoming connection request on FTP interface 0 at xxx.xxx.xxx.xxx
2011/12/13 13:48:41  [1]  FTP connection request accepted from xxx.xxx.xxx.xxx
2011/12/13 13:48:45  [1]  USER svc.script
2011/12/13 13:48:45  [1]  331 User svc.script, password please 

At this point the Coldfusion/Java client returns "Truncated server reply".  I also tried not using the login, and instead sending the user command and pass command separately like this:

userCmd = ftpsClient.sendCommand(JavaCast("string","USER" ),JavaCast("string","username" ));

But as soon as I send the "USER" command I see the above in the log file and the same reply, "Truncated server reply".

When I use the cfftp tag like this:

<cfsetting requesttimeout="1000">

<cfftp action="open" connection="ftptest" secure="false"

    server="xxx.xxx.xxx.xxx" port="21"

    username="username" password-"password" timeout="1000" stoponerror="true">

I receive a "java.net.ConnectException: Connection timed out: connect"

Does anyone have any ideas?  Thanks much.

2.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Dec 14, 2011 Dec 14, 2011

This has been resolved.

There is a bug in the apache commons ftpclient that misinterprets /r in the welcome message.  The ftp server people made a change that fixes this.

With cfftp, when I changed the server attribute on the cfftp open to the server name instead of the ip address, it started working.  To me this is a bug in ColdFusion, you should be able to use the ip address.

The other thing I noticed is when you use getfile, you have to set the the failifexists attribute to "false".  If you don'

...
Translate
Participant ,
Dec 14, 2011 Dec 14, 2011

This has been resolved.

There is a bug in the apache commons ftpclient that misinterprets /r in the welcome message.  The ftp server people made a change that fixes this.

With cfftp, when I changed the server attribute on the cfftp open to the server name instead of the ip address, it started working.  To me this is a bug in ColdFusion, you should be able to use the ip address.

The other thing I noticed is when you use getfile, you have to set the the failifexists attribute to "false".  If you don't, it fails every time and the file has a "0" size, whether the file actually does exist.  To me, another bug.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 14, 2011 Dec 14, 2011
LATEST

To me, another bug.

Make sure you log 'em:

http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html

--
Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources