Page 1 of 1

How to catch exception from TScSFTPClient or TScSSHClient

Posted: Tue 01 Jun 2010 16:16
by pfrossard
Hi,
I would like to delete the message "Connection timeout expired" when the IP address is not correct ... or catch other error,
How to do that ?
I try this but without success ...

try
ScSFTPClient.Initialize;
except
on e: EScError do
begin
AddDebugString('Error : ' + e.Message);
end;
on e: EScSFTPError do
begin
AddDebugString('Error : ' + e.Message);
end;
end;

Thanks.

Posted: Tue 01 Jun 2010 22:44
by pfrossard
I create my own Exception handler ...
But, with the SocketException the program freeze 10 seconds and I can not change this timeout, also the timeout in SSHClient or SSHShell does nothing ...

procedure TRootForm.MyExceptionHandler(Sender : TObject; E : Exception);
begin
if ((E.ClassName = 'SocketException') or (E.ClassName = 'EScError') or (E.ClassName = 'EScSFTPError')) then
begin ...

Posted: Wed 02 Jun 2010 08:33
by Dimon
The problem is that if you set the Hostname property to a server hostname, then SecureBridge uses WinSock API 'gethostbyname' function to retrieve corresponding host information. This function returns result only after 3-10 seconds if the hostname is invalid, and SecureBridge can't influence it.

Posted: Wed 02 Jun 2010 09:00
by pfrossard
I set the ScSSHClient.hostname with an IP address ?!

Posted: Wed 02 Jun 2010 13:45
by Dimon
When you use IP address then the WinSock API 'connect' function is executed, and this takes much time when this address does not exist.