session.GetFiles() stucks for some FTP server, session.TimeOut does not work

Advertisement

rakeshvb
Joined:
Posts:
1
Location:
USA

session.GetFiles() stucks for some FTP server, session.TimeOut does not work

I am trying to FTP certain file form n number of FTP connections. In some of the connections my session.GetFiles method just get stucks. I want to set a timeout of 5 seconds for per file try. I am using session.TimeOut but it does not change anything. Below is my code snippet.

SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Ftp,
HostName = "ip",
UserName = "acc",
Password = "pass",
};

using (Session session = new Session())
{
// Connect
session.Open(sessionOptions);
string pr = "x";
// Download files
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;
string dir = @"d:\test\z\"+x+@"\";
session.Timeout = TimeSpan.FromSeconds(5);

Console.WriteLine(dir);
TransferOperationResult transferResult;
transferResult = session.GetFiles("/a/b/y*.txt", dir, false, transferOptions);

// Throw on any error
transferResult.Check();

// Print results
foreach (TransferEventArgs transfer in transferResult.Transfers)
{
Console.WriteLine("Download of {0} succeeded", transfer.FileName);
}
session.Close();
}
Description: Log File

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
28,542
Location:
Prague, Czechia

Re: session.GetFiles() stucks for some FTP server, session.TimeOut does not work

As I've asked you on your duplicate question on Stack Overflow, we need a full session log file (matching debug log file would be useful too):
https://stackoverflow.com/q/50822951/850848

Reply with quote

Advertisement

You can post new topics in this forum