wood burning stoves 2.0*
The moose likes Sockets and Internet Protocols and the fly likes Problem in connecting to FTP server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Problem in connecting to FTP server" Watch "Problem in connecting to FTP server" New topic

Problem in connecting to FTP server

Manupriya Sinha

Joined: Aug 19, 2008
Posts: 4

I am using apache commons library for connecting to FTP server. Please find below the code -

Now my problem is - I do not get any exception but still ftp.getReplyString() returns '530 Login incorrect.'. Can you please help me with this.

We are using port 22 on the ftp server. Can that be the reason for this error?

I modified my code and included port as well while connecting, as folllows -
ftp.connect(addr, 22);

but now I am getting an exception -
Server Reply: SSH-1.99-OpenSSH_3.6.1p2
at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:284)
at org.apache.commons.net.ftp.FTP._connectAction_(FTP.java:335)
at org.apache.commons.net.ftp.FTPClient._connectAction_(FTPClient.java:550)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:142)
at com.novus.file.ftp.JakartaWrapperTest.main(JakartaWrapperTest.java:26)

Is it to do something with Active FTP or Passive FTP?


JCE - Please Use Code Tags
[ August 19, 2008: Message edited by: Joe Ess ]

Regards,<br />Manupriya<br /> <br />SCJP 1.4 - 98%<br />SCWCD 1.4 - 94%
Joe Ess

Joined: Oct 29, 2001
Posts: 8935

Originally posted by Manupriya Sinha:

Server Reply: SSH-1.99-OpenSSH_3.6.1p2

This reply leads me to believe that you are connecting to an SSH service, not FTP. Port 22 is usually bound to an SSH server. Port 21 is typical for an FTP server.
Have you tried connecting with an FTP client?
Are you supposed to be using SFTP (FTP over SSH)?

"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Manupriya Sinha

Joined: Aug 19, 2008
Posts: 4
Thanks a lot Joe !!

I will try code for sftp now.
jQuery in Action, 2nd edition
subject: Problem in connecting to FTP server