I have a system, where we were sending files by FTP transfer through Proxy. Now i need to make a change to send the files with or without Proxy.
I tried just creating an FTPClient
connection without host and port values and also without user id and pwd. like client = new FtpClient();
Alone this makes sending the files without Proxy?
I read about Proxy.Type.DIRECT
, not understanding the usage of that whether i should apply for my requirement.
From your code, it seems that you are using an FTP proxy (not a normal proxy).
client = new FtpClient(proxy, Integer.parseInt(port));
client.login(username+"@"+host, password);
If you want to connect directly, connect to the host
, not proxy
. Also I assume that the actual username of the target host is just a username
. The FTP proxy uses a username in format username@host
to tell, what host it should forward the connection to.
client = new FtpClient(host, Integer.parseInt(port));
client.login(username, password);
Not sure about the port. If your FTP proxy uses a non-standard port, you probably should not use the port
, but connect to a standard FTP port 21
.