C# FTP : How to Check time out and abort session

Advertisement

whitedevil91
Joined:
Posts:
6

C# FTP : How to Check time out and abort session

I currently built c# application using winscp to synchronize FTP Server to my local dir.
In C#, the session is connected to FTP server.
when comes to do directory listing using session.ListDirectory("/"), it keep stuck in the command looping and reconnect. I am sure the error is "NO Listing Directory".
this is because I set the FTP mode to passive and the firewall not accepting.

now the case is how can I test and check/trigger the timeout connection for keeping connect listing directory and abort the session to prevent the stuck in session.ListDirectory("/") command forever.

how to set the timeoutexception command in c#?
I found no example.

Thank you.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,517
Location:
Prague, Czechia

Re: C# FTP : How to Check time out and abort session

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

Reply with quote

whitedevil91
Joined:
Posts:
6

Re: C# FTP : How to Check time out and abort session

martin wrote:

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.


Hi prikryl,

the log you requested is at the attachment.

The problem is how can I TimeoutException or abort my console whenever my system face No Listing Directory in FTP server. In log.txt is running passive mode on purpose.

Thank You.

Best Regards,
whitedevil91
  • log.txt (10.35 KB, Private file)

Reply with quote

martin
Site Admin
martin avatar

Re: C# FTP : How to Check time out and abort session

The option reconnecttime is (implicitly) set to 120 and you didn't even wait that long.
Did you try to set the option to lower value?

Reply with quote

whitedevil91
Joined:
Posts:
6

Re: C# FTP : How to Check time out and abort session

martin wrote:

The option reconnecttime is (implicitly) set to 120 and you didn't even wait that long.
Did you try to set the option to lower value?

Hi prikryl ,

Here is the another generated log.txt. I set "option reconnecttime" 2 seconds.

I saw this line:
. 2015-06-11 09:58:49.899 Connection was lost, asking what to do.
. 2015-06-11 09:58:49.899 Asking user:
. 2015-06-11 09:58:49.899 Lost connection. ("Timeout detected. (data connection)","Could not retrieve directory listing")

I think these line where I saw WinSCP Application pop-out dialog ask user to choose whether abort or reconnect.
but in C# application does not pop-out the dialog. The c# application by default after reconnectime, it will reconnecting the FTP server again.

So how it allow my c# application jump out from this loop of re-connection to my FTP Server? or at least it enable to pop-out the dialog same like in WinSCP application to ask whether user want to abort or reconnect.

Thank you.

Best Regards,
whitedevil91

Reply with quote

Advertisement

martin
Site Admin
martin avatar

Re: C# FTP : How to Check time out and abort session

OK, you are right. The problem is that the connection succeeds, it's the listing that fails. So the reconnecttime option does not apply. There's no way to restrict attempts to read the directory, if the (control) connection succeeds.

Reply with quote

hammad
Guest

same problem in session.PutFiles

I am facing the same problem, when I upload file.
The file is uploaded on the sftp server, when I see form winscp GUI.
But the code gets stuck on session.PutFiles().
It throws exception of time out after 30 minutes.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,517
Location:
Prague, Czechia

Re: same problem in session.PutFiles

hammad wrote:

I am facing the same problem, when I upload file.
The file is uploaded on the sftp server, when I see form winscp GUI.
But the code gets stuck on session.PutFiles().
It throws exception of time out after 30 minutes.
The problem of this thread has been fixed already:
https://winscp.net/tracker/1169

Your problem seems to be different.
Please start a new thread and post complete log files both from GUI and the .NET assembly.

Reply with quote

Advertisement

You can post new topics in this forum