Thursday, January 30, 2014

FTP Connection error : 530 user cannot log in, but able to login using WinSCP using same credential

Hi EveryOne,


We have a File Watcher task in SSIS which is developed in C# langiage. The main functionality of the task is to look for some specific files in FTP. If files are found, check the file size, wait for 1 minute and agian recheck the filesize. If the file size is same then start another process which will do a further processing of this file.


To look for specific files in the package, all files from FTP are loaded to array and it is compared to the list of files which has to be present. Till here its working perfectly fine.


Now if the file from FileList exists in FTP, file size has to be determined.


For this below code has been written:



public String ftpConn()
{
String fleLst = searchFilesFtp();
String ftpserver = "http://ift.tt/1bbVdin;;
String ftpDirectory = "reports/";
String url = ftpserver + ftpDirectory;

String[] file = fleLst.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < ((ICollection)file).Count; i++)
{
long InitiSize = 0;
long FinalSize = 0;

FtpWebRequest reqSize = (FtpWebRequest)FtpWebRequest.Create(url + file[i]);

reqSize.Credentials = new NetworkCredential(@"usr", "pwd");

reqSize.UseBinary = true;
reqSize.UsePassive = true;
reqSize.KeepAlive = false;


long size = 0;
reqSize.Method = WebRequestMethods.Ftp.GetFileSize;
try
{
//error is in below code : "530 user cannot log in"

FtpWebResponse loginresponse = (FtpWebResponse)reqSize.GetResponse();
FtpWebResponse respSize = (FtpWebResponse)reqSize.GetResponse();
respSize = (FtpWebResponse)reqSize.GetResponse();
size = respSize.ContentLength;
respSize.Close();
}
catch (Exception e)
{
String err = e.Message;
}
while (true)
{
if (size > 0 && InitiSize > 0)
{
if (InitiSize == FinalSize)
{
fileCount_Act++;
break;
}
else
{
FinalSize = InitiSize;
// System.Threading.Thread.Sleep(60000);
}
}
InitiSize = size;
}
}
return fleLst;
}








Can some one please let me know why this error is happening and how can we resolve it.


I am able to connect to FTP using the above credentials in WinSCP.


NOTE: We have another file watcher task with same code, but for different FTP site. Its working perfectly fine there. I am not sure what exactly is the problem here.


Thanks in advance




Raksha





No comments:

Post a Comment