Delphi Service Application crashing after several hours (wodSFTP / wodSFTP.NET / wodSFTPdll)
Hi,
it happened again. this time after 4 days and 3 hours of program uptime.
The Exception was thrown by sftp.GetFiles(...) and was handled but then the application stopped.
I don't know what to try at this point.
I attached the current source code:
-CheckServerForNewFiles is called every minute by a TTimer
-sftpLoopItem is the event of the wodSFTP
-RemoveFilesFromServer deletes every remote file that was not skipped by sftpLoopItem
these methods are defined in a single TDataModule which is created when the service application is started and freed when the service is stopped.
procedure TdmTransfer.CheckServerForNewFiles;
var
filenames: TStringDynArray;
bugreport: string;
fn: string;
sftp: TwodSFTPCom;
begin
try
fFilesToBeRemoved.Clear;
CoInitialize(nil);
sftp := TwodSFTPCom.Create(self);
sftp.Connect;
sftp.LicenseKey := 'myLicenseKey';
sftp.Hostname := 'myHostname';
sftp.Login := 'myUsername';
sftp.Port := 22;
sftp.Password := 'myPassword';
sftp.Blocking := true;
sftp.Authentication := authPassword;
sftp.ProxyType := ProxyNone;
sftp.OnLoopItem := sftpLoopItem;
sftp.Connect1;
sftp.RemotePath := TSettings.Instance.RemotePath;
sftp.LocalPath := 'c:\temp\download\';
sftp.GetFiles(sftp.LocalPath, sftp.RemotePath, 1);
filenames := TDirectory.GetFiles('c:\temp\download\', '*.XML');
if length(filenames) > 0 then
begin
MoveFilesToImport(filenames);
RemoveFilesFromServer(sftp);
end
else
TLogger.AddLog('No files found');
sftp.Disconnect1;
sftp.Free;
CoUninitialize;
except
on ex: Exception do
begin
bugreport := CreateBugReport(etNormal, ex);
AddLog(bugreport);
end;
end;
end;
procedure TdmTransfer.RemoveFilesFromServer(aSFTP: TwodSFTPCom);
var
fn: string;
begin
TLogger.AddLog('Deleting files from server');
for fn in fFilesToBeRemoved do
begin
TLogger.AddLog(' ' + fn);
aSFTP.DeleteFile(fn);
end;
fFilesToBeRemoved.Clear;
end;
procedure TdmTransfer.sftpLoopItem(ASender: TObject; var LocalFile, RemoteFile: WideString; ItemType: TOleEnum;
var Skip: WordBool);
begin
Skip := pos('.XML', string(RemoteFile)) <= 0;
if not Skip then
fFilesToBeRemoved.Add(RemoteFile);
end;
Complete thread:
- Delphi Service Application crashing after several hours - Gloegg, 2014-08-05, 20:20
- Delphi Service Application crashing after several hours - wodSupport, 2014-08-05, 23:21
- Delphi Service Application crashing after several hours - Gloegg, 2014-08-06, 09:31
- Delphi Service Application crashing after several hours - wodSupport, 2014-08-06, 12:48
- Delphi Service Application crashing after several hours - Gloegg, 2014-08-06, 13:30
- Delphi Service Application crashing after several hours - wodSupport, 2014-08-06, 19:55
- Delphi Service Application crashing after several hours - Gloegg, 2014-08-07, 14:06
- Delphi Service Application crashing after several hours - wodSupport, 2014-08-07, 19:26
- Delphi Service Application crashing after several hours - Gloegg, 2014-08-11, 20:31
- Delphi Service Application crashing after several hours - Gloegg, 2014-08-12, 09:45
- Delphi Service Application crashing after several hours - wodSupport, 2014-08-12, 10:08
- Delphi Service Application crashing after several hours - Gloegg, 2014-08-12, 09:45
- Delphi Service Application crashing after several hours - Gloegg, 2014-08-11, 20:31
- Delphi Service Application crashing after several hours - wodSupport, 2014-08-07, 19:26
- Delphi Service Application crashing after several hours - Gloegg, 2014-08-07, 14:06
- Delphi Service Application crashing after several hours - wodSupport, 2014-08-06, 19:55
- Delphi Service Application crashing after several hours - Gloegg, 2014-08-06, 13:30
- Delphi Service Application crashing after several hours - wodSupport, 2014-08-06, 12:48
- Delphi Service Application crashing after several hours - Gloegg, 2014-08-06, 09:31
- Delphi Service Application crashing after several hours - wodSupport, 2014-08-05, 23:21