I have a Datasnap Delphi 10.1 Berlin server that cannot return data packets (via TStream) more than about 260,000 bytes.
I programmed it after the sample \ Object Pascal \ DataSnap \ FireDAC from Delphi, which also shows this problem.
The problem is that you can simply open this sample by running the indexFieldName value of the qOrders component on ServerMethodsUnit.pas and changing its SQL property to:
select * from Orders union select * from Orders
Now the amount of data sent exceeds 260,000 bytes, which, apparently, is the place where you can not receive it from the client. Getting EFDException [FireDAC] [Stan] -710. Invalid binary storage format.
Data is sent as a stream that you receive from the FDSchemaAdapter on the server, and you load another FDSchemaAdpater client on the client. The connection between the client and server is also FireDAC.
So the server returns this stream:
function TServerMethods.StreamGet: TStream; begin Result := TMemoryStream.Create; try qCustomers.Close; qCustomers.Open; qOrders.Close; qOrders.Open; FDSchemaAdapter.SaveToStream(Result, TFDStorageFormat.sfBinary); Result.Position := 0; except raise; end; end;
And this is how the client retrieves it:
procedure TClientForm.GetTables; var LStringStream: TStringStream; begin FDStoredProcGet.ExecProc; LStringStream := TStringStream.Create(FDStoredProcGet.Params[0].asBlob); try if LStringStream <> nil then begin LStringStream.Position := 0; DataModuleFDClient.FDSchemaAdapter.LoadFromStream(LStringStream, TFDStorageFormat.sfBinary); end; finally LStringStream.Free; end; end;
The client does not receive all the data for the Blob parameter. I save the Stream content on the server and the content that comes to the Blob parameter on the client and they are the same size, but the contents of the Blob parameter have truncated content, and the last few kilobytes are zeros.
This is how I save the content that will be streamed to Stream on the server:
FDSchemaAdapter.SaveToFile('C:\Temp\JSON_Server.json', TFDStorageFormat.sfJSON);
This is how I check what I get in the client blob parameter:
TFile.WriteAllText('C:\Temp\JSON_Client.json', FDStoredProcGet.Params[0].asBlob);
I see that the client is clearing the data.
Do you know how to fix it, or a workaround to get all Stream content from the Datasnap server for my client?
Update . I updated Delphi 10.1 Berlin Update 2, but the problem remains.
Thanks.