Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
5.8k views
in Java FTP by (300 points)
I am trying to use EditFtpj with our proxy. My code is :-

ftpc = new FTPClient();
ftpc.setRemoteHost("proxyIP");
ftpc.setRemotePort(80);
ftpc.setMessageListener(listener);
listener.clearLog();
ftpc.connect();
ftpc.login(ftpRemoteUID+"@"+ftpRemoteHost, ftpRemoteUPW);

But ftpc.connect() throws
java.io.IOException: Unexpected null reply received

6 Answers

0 votes
by (162k points)
Looks like an HTTP proxy to me (port 80), which probably doesn't support the syntax you are using. HTTP proxies aren't supported in edtFTPj.
0 votes
by (300 points)
I got the port wrong, its 21. The Proxy seems to make me log on twice, once onto the proxy, once onto the remote server.
Code something like this
ftpc = new FTPClient();
ftpc.setRemoteHost("proxyIP");
ftpc.setRemotePort(21);
ftpc.setMessageListener(listener);
listener.clearLog();
ftpc.connect();
ftpc.login(proxyUID, proxyUPW);
ftpc.user(ftpRemoteUID+"@"+ftpRemoteHost);
ftpc.password(ftpRemoteUPW);
ftpc.dir()

Seems to allow me to log on to the remote server, but then I get

DEBUG [com.enterprisedt.net.ftp.FTPControlSocket] 15 Nov 2006 14:50:12.671 : ---> PASV
DEBUG [com.enterprisedt.net.ftp.FTPControlSocket] 15 Nov 2006 14:50:12.671 : 227 Entering Passive Mode (172,16,1,17,132,149)
DEBUG [com.enterprisedt.net.ftp.FTPControlSocket] 15 Nov 2006 14:50:12.687 : ---> NLST
DEBUG [com.enterprisedt.net.ftp.FTPControlSocket] 15 Nov 2006 14:50:12.718 : 200 Command okay.
com.enterprisedt.net.ftp.FTPException: Command okay.
at com.enterprisedt.net.ftp.FTPControlSocket.validateReply(FTPControlSocket.java:872)
at com.enterprisedt.net.ftp.FTPClient.dir(FTPClient.java:2095)
DEBUG [com.enterprisedt.net.ftp.FTPControlSocket] 15 Nov 2006 14:50:12.718 : ---> QUIT
at com.enterprisedt.net.ftp.FTPClient.dir(FTPClient.java:2055)
DEBUG [com.enterprisedt.net.ftp.FTPControlSocket] 15 Nov 2006 14:50:12.796 : 150
Opening ASCII mode data connection for file list.
at com.anl.ftp.Ftp.ftpDir(Ftp.java:316)
ERROR
at com.anl.ftp.Ftp.getDir(Ftp.java:182)
at com.anl.ftp.Test.execute(Test.java:22)
at com.anl.ftp.Test.main(Test.java:28)
com.enterprisedt.net.ftp.FTPException: Opening ASCII mode data connection for file list.
at com.enterprisedt.net.ftp.FTPControlSocket.validateReply(FTPControlSocket.java:872)
at com.enterprisedt.net.ftp.FTPClient.quit(FTPClient.java:2487)
at com.anl.ftp.Ftp.ftpQuit(Ftp.java:377)
at com.anl.ftp.Ftp.disconnect(Ftp.java:132)
at com.anl.ftp.Ftp.getDir(Ftp.java:183)
at com.anl.ftp.Test.execute(Test.java:22)
at com.anl.ftp.Test.main(Test.java:28)
0 votes
by (162k points)
This is probably the problem:

DEBUG [com.enterprisedt.net.ftp.FTPControlSocket] 15 Nov 2006 14:50:12.687 : ---> NLST
DEBUG [com.enterprisedt.net.ftp.FTPControlSocket] 15 Nov 2006 14:50:12.718 : 200 Command okay.

200 isn't a valid reply for NLST.

Try using setStrictReturnCodes(false) to see if that helps. This relaxes the checks on reply codes.
0 votes
by (300 points)
I tried that and I now get:-

DEBUG [com.enterprisedt.net.ftp.FTPControlSocket] 15 Nov 2006 16:40:21.953 : ---> NLST
DEBUG [com.enterprisedt.net.ftp.FTPControlSocket] 15 Nov 2006 16:40:21.984 : 200 Command okay.
DEBUG [com.enterprisedt.net.ftp.FTPControlSocket] 15 Nov 2006 16:40:22.328 : 150 Opening ASCII mode data connection for file list.
com.enterprisedt.net.ftp.FTPException: Opening ASCII mode data connection for file list.
at com.enterprisedt.net.ftp.FTPControlSocket.validateReply(FTPControlSocket.java:872)
at com.enterprisedt.net.ftp.FTPClient.dir(FTPClient.java:2130)
DEBUG [com.enterprisedt.net.ftp.FTPControlSocket] 15 Nov 2006 16:40:22.328 : ---> QUIT
at com.enterprisedt.net.ftp.FTPClient.dir(FTPClient.java:2055)
DEBUG [com.enterprisedt.net.ftp.FTPControlSocket] 15 Nov 2006 16:40:22.343 : 226 Transfer comple
0 votes
by (162k points)
Your proxy is acting weirdly indeed.

It seems to be inserting extra replies.

Normally NLST would get back 150, and then 226 once the transfer is complete.

Your proxy is inserting an extra "200 Command okay" in the reply stream.

This just isn't going to work that I can see ... have you had any FTP clients work successfully with this?
0 votes
by (300 points)
I can get edtftpj working successfully using the sockets mode. But that's about it.

Categories

...