Hi,
I have a rtcClient Multithread=True and rtcServer MultiThread = True.
My rtcClientModule (cmProcessFileApi ) has AutoSessions = True, AutosessionPing = 10, Compression = cMax.
This API is responsible for loading and processing files. All calls are blocking.
The client calls this code:
function TmdwClient.ProcessFile(const aFileName, aAction, aParameters: String;
aFileData: TStream; var aLog: String): Boolean;
var
lFunc : TRtcFunctionInfo;
lRetval : TrtcValue;
begin
lFunc := cmProcessFileAPI.Data.NewFunction('ProcessFile');
lFunc.AsString['Action'] := aAction;
lFunc.asString['Parameters'] := aParameters;
lFunc.asString['Filename'] := ExtractFilename(aFileName);
lFunc.asByteStream['FileData'] := aFileData;
lRetVal := cmProcessFileAPI.Execute; // #1
Result := False;
aLog := '';
if lRetval.isType = rtc_Record then begin
aLog := lRetval.asRecord.asString['Log'];
Result := lRetval.asRecord.asBoolean['Success'];
end;
end;
The call will hang in #1 until the process is done. The user interface will have to wait until this event is done. This method is called from a ModalWindow so the application must wait until it returns. The file will be around 2.0 Mb.
The server gets the file with this code:
procedure TmdwServer.fncProcessFileExecute(Sender: TRtcConnection;
Param: TRtcFunctionInfo; Result: TRtcValue);
var
lAction,
lFilename ,
lFullFileName : String;
lFileData : TStream;
lParameters : TStringlist;
lRetval : TRtcValue;
lBOSession : TBOSessionData;
lExternal : TBOImportData_External;
lImportinfo : TBOImportExternalDataInfoOptions;
begin
lParameters := TStringlist.Create;
lParameters.Delimiter := ',';
lParameters.StrictDelimiter := True;
try
try
lAction := Param.AsString['Action'];
lParameters.DelimitedText := Param.asString['Parameters'];
lFilename := Param.asString['Filename'];
lFileData := Param.asByteStream['FileData'];
lBOSession := TBOSessionData( TrtcDataServer( Sender ).Session.Obj['SessionData']);
if lAction = 'Funcionários' then begin
lExternal := TBOImportData_External.Create( lBOSession );
try
lImportinfo := [];
if lParameters.Values['Unidades'] = '1' then lImportinfo := lImportInfo + [ diUnidades ];
if lParameters.Values['Cargos'] = '1' then lImportinfo := lImportInfo + [ diCargos ];
if lParameters.Values['Funcionarios'] = '1' then lImportinfo := lImportInfo + [ diFuncionarios ];
lExternal.ImportInfo := lImportInfo;
lFileData.Position := 0;
lExternal.PrepareFileName(lFileName, lFileData, lFullFileName );
lExternal.FileName := lFullFileName;
with Result.NewRecord do begin
asBoolean['Success'] := lExternal.Execute; #2
asString['Log'] := lExternal.LogData.ToString;
end;
finally
lExternal.Free;
end;
end;
except
on e:exception do begin
with Result.NewRecord do begin
asBoolean['Success'] := False;
asString['Log'] := lExternal.LogData.ToString;
end;
end;
end;
finally
lParameters.Free;
end;
end;
#2 might take some time to process. Upon success it will return True. This routine should take between 5 to 10 minutes to complete.
The problem is that after exact 30s the following error is raised:
Error: Connection problems, no response received
This application is responsive for 30s before the error is raised. (I can move the modal window).
On the server side, the call should get call on a separated thread right?
Is there something wrong with this implementation? The problem is on the server side?
Do I need to check for active thread?
I'm a bit lost, any tips would help a lot.
TIA,
Clément