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

Author Message
whitedevil91
[View user's profile]

Joined: 2015-06-03
Posts: 6
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.
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
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.
whitedevil91
[View user's profile]

Joined: 2015-06-03
Posts: 6
prikryl 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

Description: (none)

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
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?
whitedevil91
[View user's profile]

Joined: 2015-06-03
Posts: 6
prikryl 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
log.txt (45.73 KB) [Download]

Description: (none)

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
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.
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License