Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
5.9k views
in Java FTP by (360 points)
HI
My SFTP server is running on 192.168.1.107:22
My SFTP client is running on Android Phone. I'm using edtFTP/PRO evaluation copy.
I'm getting following exception.

03-12 11:15:12.244: INFO/System.out(223): INFO [DhGroup1Sha1] 12 Mar 2010 11:15:12.248 : Starting client side key exchange.
03-12 11:15:13.329: INFO/System.out(223): ERROR [ConnectTask] 12 Mar 2010 11:15:13.328 : 1:Connect[192.168.1.107:22] failed : Username and password cannot be null!
03-12 11:15:13.339: INFO/System.out(223): com.enterprisedt.net.j2ssh.authentication.AuthenticationProtocolException: Username and password cannot be null!
03-12 11:15:13.339: INFO/System.out(223):     at com.enterprisedt.net.j2ssh.authentication.PasswordAuthenticationClient.authenticate(Unknown Source)
03-12 11:15:13.339: INFO/System.out(223):     at com.enterprisedt.net.j2ssh.authentication.AuthenticationProtocolClient.authenticate(Unknown Source)
03-12 11:15:13.339: INFO/System.out(223):     at com.enterprisedt.net.j2ssh.SshClient.authenticate(Unknown Source)
03-12 11:15:13.360: INFO/System.out(223):     at com.enterprisedt.net.ftp.ssh.SCPClient.connectSSH(Unknown Source)
03-12 11:15:13.360: INFO/System.out(223):     at com.enterprisedt.net.ftp.ssh.SSHFTPClient.connect(Unknown Source)
03-12 11:15:13.360: INFO/System.out(223):     at com.enterprisedt.net.ftp.async.internal.ConnectTask.connect(Unknown Source)
03-12 11:15:13.360: INFO/System.out(223):     at com.enterprisedt.net.ftp.async.internal.ConnectTask.run(Unknown Source)
03-12 11:15:13.360: INFO/System.out(223):     at com.enterprisedt.net.ftp.async.internal.FTPTaskProcessor$_A.run(Unknown Source)
03-12 11:15:13.360: INFO/System.out(223): com.enterprisedt.net.j2ssh.authentication.AuthenticationProtocolException: Username and password cannot be null!
03-12 11:15:13.360: INFO/System.out(223):     at com.enterprisedt.net.j2ssh.authentication.PasswordAuthenticationClient.authenticate(Unknown Source)
03-12 11:15:13.360: INFO/System.out(223):     at com.enterprisedt.net.j2ssh.authentication.AuthenticationProtocolClient.authenticate(Unknown Source)
03-12 11:15:13.372: INFO/System.out(223):     at com.enterprisedt.net.j2ssh.SshClient.authenticate(Unknown Source)
03-12 11:15:13.372: INFO/System.out(223):     at com.enterprisedt.net.ftp.ssh.SCPClient.connectSSH(Unknown Source)
03-12 11:15:13.372: INFO/System.out(223):     at com.enterprisedt.net.ftp.ssh.SSHFTPClient.connect(Unknown Source)
03-12 11:15:13.372: INFO/System.out(223):     at com.enterprisedt.net.ftp.async.internal.ConnectTask.connect(Unknown Source)
03-12 11:15:13.372: INFO/System.out(223):     at com.enterprisedt.net.ftp.async.internal.ConnectTask.run(Unknown Source)
03-12 11:15:13.372: INFO/System.out(223):     at com.enterprisedt.net.ftp.async.internal.FTPTaskProcessor$_A.run(Unknown Source)
03-12 11:15:13.385: INFO/System.out(223): WARN [InternalConnectCallback] 12 Mar 2010 11:15:13.383 : One or more connections failed to succeed - disconnecting all


What can be done to resolve this problem. Please Guide me.[/code]

6 Answers

0 votes
by (51.6k points)
Hi

You need to call setUserName(String) and setPassword(String) before calling connect(). Please let us know if you've already done so.

- Hans (EnterpriseDT)
0 votes
by (360 points)
HI
Yes. I have.Infact I have logged username using sftp.getUserName() method and i'm getting correct username i have set.
Following code snippet will explain.

            sftp = new SecureFileTransferClient();


            // set remote HOST
            log.info("Setting remote HOST");
            sftp.setRemoteHost(HOST);
            log.info("Setting User Name "+USERNAME);
            sftp.setUserName(USERNAME);
            log.info("Setting Password "+PASSWORD);
            sftp.setUserName(PASSWORD);
            log.info("Setting Protocol SFTP");
            sftp.setProtocol(Protocol.SFTP);
            log.info("User Name set is : " + sftp.getUserName());
            
            // connect to the server
            sftp.connect();
0 votes
by (162k points)
Please try hardcoding the username and password into the code. I assume you are using 3.1.2.

I just ran this code:

SecureFileTransferClient ftc = new SecureFileTransferClient();
ftc.setRemoteHost("edtlinux1");
ftc.setUserName("javaftp");
ftc.setPassword("javaftp");
ftc.setProtocol(Protocol.SFTP);
ftc.connect();
ftc.disconnect();


without any problems. Could you please email your Java file to us if it still isn't working? (support at enterprisedt dot com)
0 votes
by (360 points)
HI

I got rid off above problem.
I made a silly mistake by calling setUserName method twice instead of calling setPassword. Anyway, i'm out of that problem now.

Now, I am getting following exception
ERROR [DownloadFileTask] 15 Mar 2010 10:27:50.042 : 2:Download[/sdcard/abc.txt=>abc.txt] failed : Permission denied
com.enterprisedt.net.ftp.FTPException: Permission denied
after succesfull key exchange.

i'm simply calling following function.
sftp.downloadFile("abc.txt", Environment.getExternalStorageDirectory()+"/abc.txt");
What could be the reason??
0 votes
by (360 points)
HI

Problem solved.
edtFTPj/ PRP simply rocks!!!
Thanks alot!!!
0 votes
by (51.6k points)
That's great. Now that you mention it I can see the setUserName error in your listing. I missed that first time I looked, as did you obviously.

I don't suppose you'd care to give my post on stackoverflow.com a point? Look for HansA.

- Hans (EnterpriseDT)

Categories

...