View Full Version : FileTransfer through proxy
desilvam
11-17-2009, 06:01 AM
Hi,
I am trying to do a Ftp file transfer through a FTP proxy server which only support USER command, example: USER melvin@192.168.0.5
I am using the FileTransfer class for transferring files, since I support both FTP, and FTP-SSL in my user interface. But to connect, I have use the FTP & FTPS classes to connect, since I have to issue the USER, SITE, OPEN commands for FTP.
I have no problem connecting, but I cannot get directory listing.
Any coding help/tips would be appreciated.
Here is the error:
com.jscape.inet.ftp.FtpException: 500 Unknown command.
at com.jscape.inet.ftp.AbstractRequest.assertIsPositi ve(Unknown Source)
at com.jscape.inet.ftp.MLSTRequest.execute(Unknown Source)
at com.jscape.inet.ftp.FtpBaseImplementation.getMachi neFileListing(Unknown Source)
at com.jscape.inet.ftp.Ftp.getMachineFileListing(Unkn own Source)
Here is my code:
FileTransfer fileTransfer = new FtpTransfer();
fileTransfer.setHostname(fireHost);
fileTransfer.setPort(Integer.parseInt(firePort));
ftp = (Ftp)fileTransfer.getImplementation();
ftp.connect(false);
String command = "USER " + user + "@" + host;
logResponseData(command);
ftp.issueCommand(command);
command = "PASS " + password;
ftp.issueCommand(command);
mjawwad
11-17-2009, 02:53 PM
Hi,
Use setDebug(true); before the connect() call, this will send the debug output to the console and can reveal useful information, provide this output in your response.
Best Regards,
desilvam
11-17-2009, 07:07 PM
Thanks very much for the reply. I added FileTransfer.setdebug(true); before connect call.
The FileTransfer.getDirListingAsString() works , but FileTransfer.getDirListing() fails with null pointer.
Code snippet
...
System.out.print(fileTransfer.getDirListingAsStrin g()); // this works
for(Enumeration e = fileTransfer.getDirListing(); e.hasMoreElements() ; ) //fails here
{
ar.add(e.nextElement());
}
------------------------------
OUTPUT
....
250 Directory successfully changed.
PWD
257 "/data"
PASV
227 [gateway] Enterring passive mode (192,168,0,4,5,74)
LIST
150 Here comes the directory listing.
226 Directory send OK.
drwxr-xr-x 2 26300 26300 4096 May 26 2006 ArchiveLogs06_03_04
-rw-r--r-- 1 26300 26300 22016 May 26 2006 Copy of test.ppt
drwxr-xr-x 2 26300 26300 4096 May 26 2006 encryption_keys
PASV
227 [gateway] Enterring passive mode (192,168,0,4,5,76)
LIST
150 Here comes the directory listing.
226 Directory send OK.
java.lang.NullPointerException
at com.jscape.inet.ftp.FtpBaseImplementation.getDirLi sting(Unknown Source)
at com.jscape.inet.ftp.Ftp.getDirListing(Unknown Source)
at com.jscape.inet.ftp.Ftp.getDirListing(Unknown Source)
at com.jscape.filetransfer.FtpTransfer.getDirListing( Unknown Source)
at com.hitek.engine.mods.ftp.jscape.FtpDirectoryListP arser_jscape.<init>(FtpDirectoryListParser_jscape.java:51)
mjawwad
11-17-2009, 07:32 PM
Hi,
I am not sure why you would receive a null pointer exception, I cannot see anything in the code that would do this.
Please submit a ticket to : http://www.jscape.com/support/
Include the following information in the ticket :
1) Your source code and debug log.
2) You mentioned you are using a proxy server, include these details.
3) The version of the API that you are using.
4) A test account on the server so we can debug this locally.
desilvam
11-17-2009, 07:44 PM
thanks .. I will send all the information. I have tested with 2 different proxy servers and get exact same error.
also, regarding: 3)
I am using the release in oct 2007 . version 7?
I noticed that version 8.3, nov 2009 has the following fix.
Bug Fix: Fixed issue with UnixParser class used in FTP and FTPS protocols
would updating help?
mjawwad
11-17-2009, 08:21 PM
Hi,
Try the latest version of the API (8.3.0) :
http://www.jscape.com/sftp/index.html
It just might resolve the issue here.
desilvam
11-19-2009, 03:48 PM
1) Unfortunately, I get the same error with 8.3
2) Even without using proxy server, getDirListing() does not work.
3) getDirListingAsString() & getNameListing() work, but getDirListing() does not.
4) I have tested with FileZilla server and vsFTPd 2.0.5
5) I will create a ticket and send you my junit test code, with host & test acount information.
------------------------------------------------
FileTransfer fileTransfer = new FtpTransfer();
fileTransfer.setHostname(host);
fileTransfer.setPort(21);
fileTransfer.setPassive(true);
Ftp ftp = (Ftp)fileTransfer.getImplementation();
ftp.setDebug(true);
ftp.connect(false);
String command = "USER " + user;
ftp.issueCommand(command);
command = "PASS " + password;
ftp.issueCommand(command);
fileTransfer.setPassive(true);
System.out.println("----fileTransfer.getDirListingAsString()-----");
System.out.print(fileTransfer.getDirListingAsStrin g());
System.out.println("----fileTransfer.getNameListing()-----");
for(Enumeration e = fileTransfer.getNameListing(); e.hasMoreElements(); )
{
System.out.println(e.nextElement().toString());
}
System.out.println("----fileTransfer.getDirListing()-----");
Enumeration en = fileTransfer.getDirListing();
fileTransfer.disconnect();
vBulletin® v3.7.1, Copyright ©2000-2010, Jelsoft Enterprises Ltd.