1
votes

I'm using ftp4j for FTP connection through applet to upload file. From server, I already open FTP site with port 27, targetURL = local IP address is 192.168.x.xxx, and grant access for user name FTPUser, password xxxx.

FTPClient client = new FTPClient();
client.connect(targetURL, port);
client.setType(client.TYPE_BINARY);
client.login(user, password);
fis = new FileInputStream(targetFile);
client.upload(targetFile);

It connects and uploads file successfully through applet, within internal network

However, when I try to test with external network, router is already configured by using NAT to translate the local IP to external IP: 175.136.xxx.xxx with port 47027 (already tested the FTP Connection using command), I got this error message:

user: FTPUser, password: xxxx port 47027
network: Connecting http://175.136.xxx.xxx:47027/  with proxy=DIRECT
network: Connecting http://175.136.xxx.xxx:20459/  with proxy=DIRECT
it.sauronsoftware.ftp4j.FTPException [code=425, message= Can't open data connection.]
at it.sauronsoftware.ftp4j.FTPClient.upload(FTPClient.java:2658)
at it.sauronsoftware.ftp4j.FTPClient.upload(FTPClient.java:2539)
at it.sauronsoftware.ftp4j.FTPClient.upload(FTPClient.java:2410)

As from the error log, it tried to establish the connection through port 47027, then after that change to 20459 (that I do not know where it comes from).

I can see the file is created in the server FTP site, but with 0 byte.

Anyone knows what's wrong with this situation?

1

1 Answers

0
votes

Use passive mode instead. Your side might be blocking the port.