Tuesday, 3 September 2013

FTP connection timeout error while trying upload file remote server

FTP connection timeout error while trying upload file remote server

Here is my problem. I am trying to upload files from my local to a remote
ftp server.But i get an connection timeout exception or files could not
upload. If i do it on local it works but for remote server it does not. I
am trying to upload files in passive mode.
If i try;
ftpClient.enterLocalPassiveMode(); //it gives timeout error,
ftpClient.enterRemotePassiveMode(); //it gives files could not upload.
I organize filezilla setting in windows firewall for both sides(my local
and remote server). Here is a piece of my code;
FTPClient ftpClient = new FTPClient();
try {
// connect and login to the server
ftpClient.connect(server, port);
ftpClient.login(user, pass);
// use local passive mode to pass firewall
ftpClient.enterLocalPassiveMode();
System.out.println("Connected");
String remoteDirPath = "/Upload";
String localDirPath = "C:/Users/nexgen/workspace/codes/pak";
FTPUtil.uploadDirectory(ftpClient, remoteDirPath, localDirPath, "");
// log out and disconnect from the server
ftpClient.logout();
ftpClient.disconnect();
System.out.println("Disconnected");
} catch (IOException ex) {
ex.printStackTrace();
}
Kind Regards.

No comments:

Post a Comment