Error '500' & 'Connection timeout' in SecureFTP using WinSCP
We use WinSCP tools (WinSCP.exe, WinSCP.dll) for our C# Project for SecureFTP. Attaching the WinSCP DLL & INI files as a Zip file to know about their versions.
We connect to WinSCP for Secure FTP of different files to different FTP Servers simultaneously.
Getting the error "The remote server returned an error: (500) Syntax error, command unrecognized." most of the times.
Getting "Network error: Connection timed out." also at some times.
These errors are not occurring for the same file/server each time.
So, not able to find out the pattern when the error occurs.
These errors are not related to : Size of the file or connecting to same server simultaneously using Threads.
Please go through the code part given below and let me know what could be reason for errors.
This is the code part related to WinSCP which will be called every time a File has to be FTP-ed :
Session Options setting :
SessionOptions sessionOptions = new SessionOptions
{
FtpMode = FtpMode.Passive,
Protocol = Protocol.Sftp,
HostName = ftpServerIP,
UserName = ftpUserID,
Password = ftpPassword,
GiveUpSecurityAndAcceptAnySshHostKey = true
};
using (Session session = new Session())
{
session.ExecutablePath = CurrentPath + "WinSCP_EXE\\WinSCP.exe";
session.IniFilePath = CurrentPath + "WinSCP_EXE\\WinSCP.ini";
session.Open(sessionOptions);
try
{
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Automatic;
TransferOperationResult transferResult;
transferResult = session.PutFiles(sourcePath, remotePath, false, transferOptions);
transferResult.Check();
foreach (TransferEventArgs transfer in transferResult.Transfers)
{
// Display transfer.FileName
}
}
catch()
{
//Contents of Exception Handling
}
finally
{
session.Dispose();
}
Please let me know what could be reason of the error and why it fails at different place and different times. Thanks in advance, for the help.
We connect to WinSCP for Secure FTP of different files to different FTP Servers simultaneously.
Getting the error "The remote server returned an error: (500) Syntax error, command unrecognized." most of the times.
Getting "Network error: Connection timed out." also at some times.
These errors are not occurring for the same file/server each time.
So, not able to find out the pattern when the error occurs.
These errors are not related to : Size of the file or connecting to same server simultaneously using Threads.
Please go through the code part given below and let me know what could be reason for errors.
This is the code part related to WinSCP which will be called every time a File has to be FTP-ed :
Session Options setting :
SessionOptions sessionOptions = new SessionOptions
{
FtpMode = FtpMode.Passive,
Protocol = Protocol.Sftp,
HostName = ftpServerIP,
UserName = ftpUserID,
Password = ftpPassword,
GiveUpSecurityAndAcceptAnySshHostKey = true
};
using (Session session = new Session())
{
session.ExecutablePath = CurrentPath + "WinSCP_EXE\\WinSCP.exe";
session.IniFilePath = CurrentPath + "WinSCP_EXE\\WinSCP.ini";
session.Open(sessionOptions);
try
{
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Automatic;
TransferOperationResult transferResult;
transferResult = session.PutFiles(sourcePath, remotePath, false, transferOptions);
transferResult.Check();
foreach (TransferEventArgs transfer in transferResult.Transfers)
{
// Display transfer.FileName
}
}
catch()
{
//Contents of Exception Handling
}
finally
{
session.Dispose();
}
Please let me know what could be reason of the error and why it fails at different place and different times. Thanks in advance, for the help.