Dear Friends,
I need to transfer the file from UNIX server to Open VMS server.
I am able to connect both the server using FTPClient, but while transfering, I need to passivate one server and activate second server. Passivating to server is working fine, but the Activating the second server is giving below error....
"501 IP Address for data destination doesn't match client's."[/size]
below is the code.....
FTPClient ftp1, ftp2;
ProtocolCommandListener listener;
String UnixServer = "XXXX.XX.XX.XXX";
String UnixUserName = "XXXXX";
String UnixPassWord = "XXXXXX";//"
String VMSServer = "XXXX.XXX.XXX.XXX";
String VMSUserName = "XXXXX";
String VMSPassWord = "XXXXXX";
listener = new PrintCommandListener(new PrintWriter(System.out));
ftp1 = new FTPClient();
ftp1.addProtocolCommandListener(listener);
ftp2 = new FTPClient();
ftp2.addProtocolCommandListener(listener);
try
{
int reply;
ftp1.connect(UnixServer);
System.out.println("Connected to " + UnixServer + ".");
reply = ftp1.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply))
{
ftp1.disconnect();
System.err.println("FTP server1 refused connection.");
System.exit(1);
}
}
catch (IOException e)
{
if (ftp1.isConnected())
{
try
{
ftp1.disconnect();
}
catch (IOException f)
{
// do nothing
}
}
System.err.println("Could not connect to server1.");
e.printStackTrace();
System.exit(1);
}
try
{
int reply;
ftp2.connect(VMSServer);
System.out.println("Connected to " + VMSServer + ".");
reply = ftp2.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply))
{
ftp2.disconnect();
System.err.println("FTP server2 refused connection.");
System.exit(1);
}
}
catch (IOException e)
{
if (ftp2.isConnected())
{
try
{
ftp2.disconnect();
}
catch (IOException f)
{
// do nothing
}
}
System.err.println("Could not connect to server2.");
e.printStackTrace();
System.exit(1);
}
try
{
int UnixReply;
int VMSReply;
ftp1.login(UnixUserName, UnixPassWord);
UnixReply = ftp1.getReplyCode();
if(!FTPReply.isPositiveCompletion(UnixReply)) {
ftp1.disconnect();
System.exit(1);
System.out.println("ftp1 bad 1");
}
ftp2.login(VMSUserName, VMSPassWord);
VMSReply = ftp2.getReplyCode();
if(!FTPReply.isPositiveCompletion(VMSReply)) {
ftp2.disconnect();
System.exit(1);
System.out.println("ftp2 bad 2");
}
ftp2.enterRemotePassiveMode();
ftp1.enterRemoteActiveMode(InetAddress.getByName(ftp2.getPassiveHost()),
ftp2.getPassivePort());
if (ftp1.remoteRetrieve("DZSCR4TEST.TEXT") && ftp2.remoteStoreUnique("DZSCR4TEST.TEXT"))
{
// if(ftp1.remoteRetrieve(file1) && ftp2.remoteStore(file2)) {
// We have to fetch the positive completion reply.
ftp1.completePendingCommand();
ftp2.completePendingCommand();
}
else
{
System.err.println("Couldn't initiate transfer. Check that filenames are valid.");
}
}
catch (IOException e)
{
e.printStackTrace();
System.exit(1);
}
finally
{
try
{
if (ftp1.isConnected())
{
ftp1.logout();
ftp1.disconnect();
}
}
catch (IOException e)
{
// do nothing
}
try
{
if (ftp2.isConnected())
{
ftp2.logout();
ftp2.disconnect();
}
}
catch (IOException e)
{
// do nothing
}
}
}
Note : I am getting above error on this line.
Error: 501 IP Address for data destination doesn't match client's.
line : ftp1.enterRemoteActiveMode(InetAddress.getByName(ftp2.getPassiveHost()),ftp2.getPassivePort());