EldoS | Feel safer!

Software components for data protection, secure storage and transfer


Posted: 06/03/2010 19:34:37
by Robert  (Basic support level)
Joined: 05/29/2010
Posts: 6

TElSimpleSftpClient->OnDNSResolve event description is missing in documentation. There are a lot of pramaters and I do not know hot to use ist.

Moreover I cannot get the TElSimpleSftpClient->OnDNSResolve event to be fired.

SftpClient->OnError event also not fired when the host name cannot be resolved.

The goal is, to tell the user Host-Error like "Cannot resolve host" instead of "Connection failed (error code is -1)"

Hmm... maybe I'm wrong and not understand the mechanism correctly. Please help. I'm using BCB 2009.
Posted: 06/04/2010 10:17:42
by Alexander Ionov (Team)

Thank you for your question. To have the task done, you should set DNS.Enabled to True and DNS.UseSecurity to False. After this when you call the ElSimpleSftpClient.Open method and if the host name is not valid you will get an EElSocketError exception with ErrorCode = SB_SOCKET_ERROR_INVALID_ADDRESS.
Also you can handle OnDNSResolve event to get an idea of failure reason (see the ResolveResult parameter of the event). The possible results are (the constants are defined in SBDNSSECConsts unit):
SB_DNS_RESULT_NAME_NOT_FOUND - host name was not found
SB_DNS_RESULT_INFO_NOT_FOUND - the host name does not have an IP address assigned (no A nor AAAA record in DNS)
SB_DNS_RESULT_SERVER_FAILURE - failed to talk to DNS server (any communication error)
SB_DNS_RESULT_TIMEOUT - failed to get an answer during the period specifed in TotalTimeout parameter.

Best regards,
Alexander Ionov
Posted: 06/05/2010 04:05:25
by Robert  (Basic support level)
Joined: 05/29/2010
Posts: 6

Thsnks for your advise.

I've set 'SftpClient->DNS->Enabled = True' and 'SftpClient->DNS->UseSecurity = False'

Still there is no EElSocketError raised (nor the SftpClient->OnError event is triggered without try .. catch).

The OnDNSResolve event is calles only once, and the ResolveResult param is allways '0' regardless if host exists or not.

Site-Search on eldos.com to the related topics, like 'UseSecurity', 'OnDNSResolve' and furhter, do not bring any results.

All other functions seems to runing nice. I put SimpleSftpClient in some threads and set 'ThreadSafe' to True. Site-Search for 'ThreadSafe' does not bring any helpfull result, therefore I basicly do not know if 'ThreadSafe' is right in this case.

Please help.

   TElSimpleSFTPClient* SftpClient    = new TElSimpleSFTPClient(NULL);
   SftpClient->KeyStorage             = FKeyStorage;
   SftpClient->OnDNSResolve         = SftpClientDNSResolve;
   SftpClient->OnAuthenticationFailed    = SftpClientAuthenticationFailed;
   SftpClient->OnAuthenticationSuccess = SftpClientAuthenticationSuccess;
   SftpClient->OnCloseConnection       = SftpClientCloseConnection;
   SftpClient->OnError             = SftpClientError;
   SftpClient->OnKeyValidate          = SftpClientKeyValidate;
   SftpClient->OnProgress             = SftpClientProgress;
   SftpClient->ThreadSafe            = True;

   SftpClient->DNS->Enabled         = True;
   SftpClient->DNS->UseSecurity      = False;
   SftpClient->Address             = "no-such-host.xyz";
   SftpClient->Port                = 22;
   SftpClient->Username             = "no_such_user";
   SftpClient->Password             = "nosuchpass";

   try {
   catch(EElSocketError &es) {
      Log((AnsiString)"Socket connection failed: " + IntToStr(es.ErrorCode));
   catch(Exception &e)
      Log((AnsiString)"Sftp connection failed by some other error: " + e.Message);
Posted: 06/05/2010 09:24:51
by Robert  (Basic support level)
Joined: 05/29/2010
Posts: 6

In the meanwhile I found out, that it works when

TStringList* dnss = new TStringList;

SftpClient->DNS->Port = 53;
SftpClient->DNS->Servers = dnss;

... is also given.
Posted: 06/07/2010 02:21:15
by Alexander Ionov (Team)

Actually the port number (DNS->Port property) should be automatically set to 53 on creating an instance of ElSimpleSftpClient. And if the list of DNS servers is not specified, this list should be loaded from your system settings automatically.
Could you please check this supposed behavior and if it fails, please create a ticket in our HelpDesk.

Thank you.

Best regards,
Alexander Ionov



Topic viewed 2211 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!