You are not logged in.
UPDATE
After several days, I can now confirm that log compression (synlz, gz and Zip) works. I've tried and tested all 3 options successfully.
In addition, I was pleasantly surprised to discover that zip compression creates log archives grouped into months and years YYYYMM.zip. for example, a new Zip archive has just been created for the current month, September, while the old archive for August is still there with August log files inside it. It is nice to have this option for certain use cases.
Thanks a lot to ab and all the other contributors to mORMot for such a wonderful framework.
Cheers,
JD
ab wrote:Please follow the forum rules
and DO NOT put such code in the forum threads.Very strange. But other forum members also post code. They are fine, they don't get any comments. Then make comments to others. And yet, regarding my question, will they answer me on the topic? Or is making a comment a way to avoid answering?
@Terinel
You don't get it. If you post code at all, keep it very brief. I try to aim for approximately 10 lines or fewer; and if it is longer or for logs, I now use an online paste service like Paste.ee https://paste.ee/. There are many others like that available.
Apparently, it is necessary to do this in order not to overload this site's server.
Just my 2 cents.
Cheers,
JD
@flydev Thanks a lot for the link.
@ab and @Coldzer0
Thanks a lot for your advice. I've added your suggestions. I'll keep you posted on the results.
Cheers,
JD
Yes, the joke is on me ;o) . I added it to the EventArchiveZip function in the mormot.core.zip source file as follows:
function EventArchiveZip(
const aOldLogFileName, aDestinationPath: TFileName): boolean;
var
n: integer;
z, s: TStream;
fsize: Int64;
ftime: TUnixMSTime;
zipname, decname: TFileName;
begin
result := false;
EventArchiveZipSafe.Lock;
LogCompressAlgo := AlgoGZFast; // <----- New addition to compress log files in GZ format
//---- more code follows -----
end;
However what this means is that I'll have to remember to add this like every time I update mORMot 2. So is it possible for you to modify the source so that the compression algorithm can be an option to be defined without having to touch mORMot 2 source files?
Thanks a million for your kind assistance.
Cheers,
JD
Just assign AlgoGZFast() mormot.core.zip.pas into LogCompressAlgo global.
Thanks for your advice, ab. Much appreciated.
How do I assign AlgoGZFast into LogCompressAlgo? Do I have to modify the mormot.core.zip.pas to do this?
Cheers,
JD
Hi there ab,
Thanks for the reply. I finally got it to rotate in the Docker container. I thought that a new log file will be created automatically immediately if it is past midnight because of the RotateFileDailyAtHour setting.
This morning, yesterday's log file was the only one in use, but when I made some requests to the server, it compressed yesterday's log file in the synlz format and created a new log file for today. I did not need to remove LogFamily.PerThreadLog := ptIdentifiedInOneFile; for this to work.
Now the next question is, can the archives be in the Zip format instead of synlz?
Thanks for your assistance.
Cheers,
JD
Hi there everyone,
I would like my server to generate log files where events are recorded using local time (not UTC), limited to 10MB in size and rotated daily at midnight.
This is my current setting
LogFamily := SQLite3Log.Family;
LogFamily.Level := LOG_VERBOSE;
LogFamily.PerThreadLog := ptIdentifiedInOneFile;
LogFamily.LocalTimestamp := TRUE; // Log events in local time
LogFamily.RotateFileCount := 1; // > 0 enables RotateFileSizeKB / RotateFileDailyAtHour
// = 1 means logs are not compressed
// File will be rotated by size and hour
LogFamily.RotateFileSizeKB := 10*1024; // rotate by 10 MB logs
LogFamily.RotateFileDailyAtHour := 0; // Midnight
ApplicationPath := Executable.ProgramFilePath;
LogFamily.DestinationPath := ExpandFileName(ApplicationPath + 'log\');
LogFamily.FileExistsAction := acAppend;
Is this correct? I cannot test the settings natively on Windows for now, but my tests in a Docker container did not yield the desired results.
In addition, I would like to know if it is possible to compress old log files in the ZIP format instead of the default synlz format if necessary.
Thanks a lot for your kind assistance.
Cheers,
JD
I can't find anything wrong. Any suggestions?
Can you try this:
aServer.ServiceRegister(TInvoiceService, [TypeInfo(IInvoiceService)], '1'); // <---- replacing InvoiceService with TInvoiceService
JD
Thank you very much for the clarification, ab.
By the way, the interface is defined as follows
TRestMethods = class(TInjectableObjectRest, IRoot)
Is TInjectableObjectRest the best thing to use here or does mORMot 2 propose a better alternative?
Cheers,
JD
Hi there ab,
Thanks a million!!! It now works! Using sicShared instead of sicClientDriven was the difference.
I'm a little bewildered though because our old mORMot 1 based REST server in production uses sicClientDriven and it works fine.
Initially, the REST server was the backend for multiple FreePascal clients, but they were discontinued and browser/Java clients were introduced, BUT the REST server remained unchanged throughout the transition.
What is the difference between sicShared and sicClientDriven in mORMot 2 and why is sicShared better?
Thanks for finding the time to help me on a Sunday evening.
Cheers,
JD
Put a breakpoint in TRestServer.Uri and make a GET on /api/service/v2/root/sayhello.
If it does not reach there, try /api/service/v2/timestamp then /api/service/v2 and /api/service/v2/rootAt least /api/service/v2/timestamp should always respond from the browser.
Hi there ab,
I did it and just as you said, /api/service/v2/timestamp works and returns a timestamp value.
However, the others did not work at all, and it still says {"errorCode": 400, "errorText": "Invalid URI"}
Stepping through the TRestServer.Uri procedure, I noticed that on the following conditional test on line 7627,
if (node = nil) or (ctxt.fNode = rnNone) then
the value of node was nil for all the other URIs I tested above except for the timestamp URI and hence the error below was generated
ctxt.Error('Invalid URI', HTTP_BADREQUEST) // root ok: error 400, not 404
Here is a link to the log file https://paste.ee/p/mgq9r
That is as far as I've gone at the moment. Any further help/suggestions will be most welcome.
Cheers,
JD
Hi there ab,
Thanks for the quick reply. I normally get mORMot 2 from GitHub https://github.com/synopse/mORMot2. I just download the zip file provided by the Code button and extract it to a local directory in my Lazarus installation. I just did that and I still got the same invalid URI result.
Is there any other version elsewhere?
Cheers,
JD
Hi there everyone,
I have been tasked with migrating an existing legacy mORMot 1 interface based REST server to mORMot 2. I have a function called SayHello that is called/tested using Postman, Insomnia etc like this: http://localhost:8088/api/service/v2/root/sayhello?params={\"db\":\"maindb\"}
This works in mORMot 1 but after migration to mORMot 2, I keep getting {"errorCode": 400, "errorText": "Invalid URI"} via TRestServerRoutingRest according to the logs.
I have combed through the forum for a solution and what I found seem to relate to method based services, for example https://synopse.info/forum/viewtopic.ph … 930#p40930.
This is how I start the interface services REST server,
procedure TServerDaemon.Start;
begin
Model := TOrmModel.Create([], 'api/service/v2'); // URI is on 'api/service/v2'
RestServer := TRestServerFullMemory.Create(Model, false);
// Define the service server side since service was previously registered in the RESTInterface unit
ServiceFactoryServer := TServiceFactoryServer(RestServer.ServiceDefine(TRestMethods, [IRoot], TServiceInstanceImplementation.sicClientDriven));
ServiceFactoryServer.SetOptions([], [optErrorOnMissingParam]);
HttpServer := TRestHttpServer.Create('8080', [RestServer], '+', HTTP_DEFAULT_MODE, 32, TSQLHttpServerSecurity.secSynShaAes);
end;
There services are consumed by web browsers. There is no Delphi/FPC client. I would really appreciate your help in the solving this problem because we would really like to try the new features of mORMot 2 in a production setting.
Thanks a million,
JD
Hi there everyone,
I'm trying to convert the 04 HTTP Client-Server sample from mORMot 1 to mORMot2. Everything has gone well so for except for the Project04Client.lpr file which did not compile.
I finally got it to compile in the form below:
program Project04Client;
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms,
SysUtils,
mormot.rest.http.client, // For TRestHttpClient
mormot.orm.rest, // For TRestOrm (note: TRest replaced TSQLRest and is in the mormot.rest.core unit)
//mORMot,
//mORMotHttpClient,
Unit1 in '..\01 - In Memory ORM\Unit1.pas' {Form1},
SampleData in '..\01 - In Memory ORM\SampleData.pas';
{$R *.res}
var Server: AnsiString;
begin
RequireDerivedFormResource := True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Form1.Caption := ' Sample 04 - HTTP Client';
if ParamCount=0 then
Server := 'localhost' else
Server := AnsiString(Paramstr(1));
TRestHttpClient(Form1.Database) := TRestHttpClient.Create(Server,'8080',Form1.Model); // <<<< Problem here
TRestHttpClient(Form1.Database).SetUser('User','synopse'); // <<<< Problem here
//Form1.Database := TSQLHttpClient.Create(Server,'8080',Form1.Model);
//TSQLHttpClient(Form1.Database).SetUser('User','synopse');
Application.Run;
end.
However when I run it and try to add data, I get Access Violation errors.
The Lazarus code editor tells me that there is a problem on these lines even though the program compiled.
TRestHttpClient(Form1.Database) := TRestHttpClient.Create(Server,'8080',Form1.Model);
TRestHttpClient(Form1.Database).SetUser('User','synopse');
It places a warning icon on the lines and the warning says Warning: class types "TRestOrm" and "TRestHttpClientSocket" are not related.
In the mORMot 1 version, the "Database" variable was of the type "TSQLRest" but in this mORMot 2 conversion, I replaced "TSQLRest" with "TRest" and even "TRestOrm" but I still get the same access violation issue.
Can anyone help me get around this problem?
Thanks a lot,
JD
Hi there ab,
Thanks a lot for your reply and clarification.
This is what it looks like now after applying your suggestions. I replaced tmMainConnection with tmThreadPool, and TSqlDBZEOSConnectionProperties with TSqlDBPostgresConnectionProperties.
//
try
DbProps := TSqlDBPostgresConnectionProperties.Create(..... PostgreSQL connection string.....);
// Use a threadpool for connections
TSqlDBPostgresConnectionProperties(DbProps).ThreadingMode := tmThreadPool;
// Automatically reconnect after a reconnection error
DBProps.ReconnectAfterConnectionError := true;
// Timeout unused connection after 12 hours
DbProps.ConnectionTimeOutMinutes := 720; // Try 60 minutes or more e.g 60 * 12 i.e 12 hours
except
on E: Exception do begin
WriteLn(StringToUTF8(E.Message));
end;
end;
Cheers,
JD
Hi there everyone,
I would like some advice on how to properly use ReconnectAfterConnectionError and ConnectionTimeOutMinutes. My code snippet is shown below.
//
try
DbProps := TSqlDBZEOSConnectionProperties.Create(..... PostgreSQL connection string.....);
// To prevent PostgreSQL from hitting the default maximum connection limit of 100
// and after rejecting subsequent connections
TSqlDBZEOSConnectionProperties(DbProps).ThreadingMode := tmMainConnection;
// Automatically reconnect after a reconnection error
DBProps.ReconnectAfterConnectionError := true;
// Timeout unused connection after 12 hours
DbProps.ConnectionTimeOutMinutes := 720; // Try 60 minutes or more e.g 60 * 12 i.e 12 hours
except
on E: Exception do begin
WriteLn(StringToUTF8(E.Message));
end;
end;
Basically, what I want to achieve is
a) automatically reconnect with the database if the connection is lost
b) timeout unused connection after 12 hours because the server is on 24/7, so this may help with long term stability
Am I doing the right thing in the code snippet above? If not, what should I be doing?
Thanks for your kind advice and input.
Cheers,
JD
I have a mORMot 1 server in a Docker container built from Alpine Linux in production, and it runs without problems. However, my server's Docker build is based on the FreePascal example https://wiki.freepascal.org/Docker_Containerization
I later discovered and tried the mORMmot 2 based 07-HttpDockerORM example in a Docker container, and it worked for me. No AV issues at all.
However, I have to clarify that my development environment is Linux Mint and I adopted Docker because I did not want to create Windows & Mac versions of my mORMot server.
JD
Hi there everyone,
In the end, I decided to rewrite the server app, making sure to remove the dependency on mormot_cross, and I'm pleased to say it now works as expected.
Cheers,
JD
Hi there ab,
I have an application that is a GUI application on Linux and a service on Windows. They both work very well.
I want to make a service/daemon on Linux using the same simple service source code that already works on Windows. But when I compile the program, I get the error below:
SynCrossPlatformREST.pas(2918,15) Error: Incompatible types: got "Variant" expected "TID"
/// marshall {result:...,id:...} and {result:...} body answers
function CallGetResult(const aCall: TSQLRestURIParams; var outID: TID): variant;
{$ifndef ISSMS}
var doc: TJSONVariantData;
jsonres: string;
{$endif}
begin
...
outID := doc.Value['id']; // <---- Error ocurs here !
{$endif}
end;
Someone else has reported the error, but it was erroneously posted in the mORMot2 section here. However no solution to the problem was posted.
My environment
Lazarus; 2.2.6 x86_64-linux-gtk2
FPC; 3.2.2
mORMot; 1.186435
What I find strange is this only occurs when I try to compile the program as a service on Linux. There are no problems at all with the other cases.
Thanks a lot for your assistance.
Cheers,
JD
squirrel wrote:Does anybody still have copies of these gists available? I need a mormot server with oauth authentication and was hoping this would be something to build on. But the gists seem to be all gone already.
email sent
Hi there Prometheus,
Could you please send me the copies by email too?
Thanks a lot
JD
I have a similar Use Case and I manage it using PostgresSQL and its schemas. Each schema houses a different database belonging to different companies.
The REST call contains the name of the schema and that way a different select/insert/delete can be accessed depending on the schema in the REST call.
For example, I use this REST call to find out if my mORMot server is up and running:
http://localhost:8088/service/myapi/sayhello?schema=company_xyz
This will call the SayHello resource in the Company_XYZ schema.
I hope this helps a little.
Cheers,
JD
Another option is to create a TSQLRestRoutingREST to be used by the service and override the ExecuteSOAByInterface method to handle the error.
Using this approach, I can send a custom error and messagem on an interface-based service.
However, since you want to validate the type of data, it would be best to use method-based services.
@macfly
Would you mind sharing some code showing how you did this? I think it might be a solution for one of my use cases because I also use an interface based service.
THanks,
JD
Because there is already a REST/ORM layer in mORMot.
OK. I get it now. I had to bypass the ORM because I have a lot of legacy code (triggers, functions and procedures) in my PostgreSQL database.
Ignoring that and going full ORM is a mammoth task that cannot be undertaken at the moment. I'll have to do it very slowly to not break something in the system.
JD
IF you reinvent the wheel, you would rather not use an interface based service, but a method-based service.
Anyway, I am a "purist" so for me, you should better follow DDD or KDD parterns, and define a proper application level, not expose directly your customer objects.
That is, start from the end-user use cases, not the data.
Thanks for your reply & your suggestions ab.
However I do not understand why you think I am reinventing the wheel.
Please clarify.
Thanks a lot,
JD
Hello there everyone,
I would like to know your opinions/experiences with designing and using a REST endpoint in mORMot that handles many parameters.
Currently my proposed function signature is like this
function TRESTMethods.Customer(Params: UTF8): RawJSON;
In order to enable customer searches by firstname, lastname, age, sex, telephone, country, dateoffirstpurchase, dateoflastpurchase etc instead of using GET, I intend to use a POST to pass a JSON document with the parameters to the server for processing. However, I've seen some say online that one can use standard GET query but with optional parameters. How is this done?
This same function will handle customer creation (using POST), modification (using PUT), deletion (using DELETE) like this:
case Ctxt.Request.Method of
mGET:
{ code for handling GET requests}
mPOST:
{ code for handling POST requests}
mPUT:
{ code for handling PUT requests}
mDELETE:
{ code for handling DELETE requests}
end;
However, I've seen some purists say that a method like this is doing too much and that it is better to break it up into smaller bits. I agree that the Customer function will be very long if I continue like this especially with the INSERT and UPDATE SQL statements needed to create and update Customer data. This is where I would like your input. How should I break up the function? Is this what Microservices architecture tries to do?
Thanks for your kind assistance,
JD
Hello there everyone,
I need a little clarification concerning the way the mORMot framework returns the standard REST codes e.g 200, 202 , 204, 404 etc.
I want to look for these codes in the messages received from my mORMot server by the RESTful clients of my application (Java & Lazarus/FPC) and display appropriate messages to the users.
How do I implement this functionality in my mORMot server and where do I look for the codes in the messages sent by the server to my clients?
Thanks a lot for your kind assistance.
JD
I guess this code might be slightly better since it will get the pointer just one time:
with _Safe(vJSON.id)^ do for intX := 1 to 10 do AddItem(intX);
or local variable can be also an option.
Anyway, these are just details, of course.
Yes that works also. Thanks a lot.
JD
Thanks a lot for your contributions. I found that this worked for me also:
procedure TForm1.Button3Click(Sender: TObject);
var
vJSON: Variant;
intX: integer;
begin
vJSON := _Json('{"id":[]}');
//
for intX := 1 to 10 do
_Safe(vJSON.id)^.AddItem(intX);
ShowMessage(VariantToUTF8(vJSON));
end;
JD
That's very strange. I'm using Lazarus 2.1.0/FPC 3.2 (built with fpcupdeluxe) on Windows 10. It used to work perfectly but I only just noticed it failed 2 daya ago when I could no longer save new records to my database.
JD
I guess the error comes from
vJSON := _Json('{id:[]}');
Try
vJSON := _Json('{"id":[]}');
Also I think there is no need in
TDocVariant.New(vJSON);
Thanks for your reply but it still does not work. I still get the same error.
By the way, I used the same method at the example in https://synopse.info/files/html/Synopse … l#TITLE_39
There we have
var V: variant;
...
V := _Json('{arr:[1,2]}');
V.arr.Add(3); // will work, since V.arr is returned by reference (varByRef)
writeln(V); // will write '{"arr":[1,2,3]}'
So even this example from the documentation does not work anymore.
JD
Hi there everyone,
I want to create a simple JSON object with a list of IDs like this: {id: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]}. I want to later loop over the array and save the IDs to a database.
This is the code I want to use to create the array is this:
// Create a JSON object like this:
// {id: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]}
//
procedure TForm1.Button1Click(Sender: TObject);
var
vJSON: Variant;
intX: integer;
begin
//
TDocVariant.New(vJSON);
vJSON := _Json('{id:[]}');
//
for intX := 1 to 10 do
vJSON.id.Add(intX);
end;
However, the code fails on
vJSON.id.Add(intX);
with the message No variant method call dispatch.
What am I doing wrong?
Thanks a lot,
JD
@radexpol
Thanks for sharing your experience. I am quite interested in how you solved your problem. If you do go ahead and create a github repo, it will certainly be most welcome from people like me.
JD
To check is the problem in Zeos itself or in SynDBZeos you can debug a TSQLDBZEOSStatement.ColumnsToJSON function. Here in line 1278 there is a condition define. Depends on it either Zeos serialization or Syn is used. In case of Syn serialization you can check is date returned correctly from Zeos layer.
The line
fResultSet.ColumnsToJSON(WR,fJSONComposeOptions);
is disabled for me because
{.$DEFINE USE_SYNCOMMONS} //enable JSON content support by using SynCommons.pas from Synopse project
is disabled in line 70 of Zeos.inc.
When I enabled it to try the ColumnsToJSON function, I get the following error messages in SynDBZeos and the compilation fails
Compile Project, Mode: Debug, Target: C:\....\Serveur.exe: Exit code 1, Errors: 5
SynDBZeos.pas(334,26) Error: Identifier not found "TZJSONComposeOptions"
SynDBZeos.pas(334,46) Error: Error in type definition
SynDBZeos.pas(413,34) Error: Identifier not found "TZJSONComposeOptions"
SynDBZeos.pas(414,15) Error: Property cannot have a default value
SynDBZeos.pas(414,16) Error: Identifier not found "jcoEndJSONObject"
This happens ONLY after I uncomment/enable line 70 of Zeos.inc
JD
@JD
Which complier are you using? And which compile target(platform)?Try to comment line
{$DEFINE INTEL_ASM} //allow intel syntax assembler
in \src\Zeos.inc. I didn't change many things lately in Postgres except switching procedure Revers4Bytes and Reverse8Bytes to asm. Maybe this fails. I'm not a asm guru.. It perfectyl works on Windows even with 64Bit..
Regards, Michael
Hello Michael,
I am using Lazarus 2.1/FPC 3.2rc1 Win32 svn 62815 running on Windows 10 Professional (x64). I only create Win32 executables.
I tried your suggestion and it did not work, unfortunately. The problem remains.
JD
Can you change some date to day<13, all bad dates have day > 12(months) just a hint
The constraints take care of bad dates so that is not the problem. Querying the database directly or using SynDBPostgres/FetchAllAsJSON gives me the right results; Zeos/FetchAllAsJSON does not.
@JD - Postgres have many "date" types. You can help a Zeos maintainer ( @EgonHugeist on this forum ) if you provide exactly a type of column (as it visible in DBeaver or pgAdmin).
BTW ODBC will be definitely slower compared to Zeos or SynDBPostgres - they both use a direct libpq binding, while ODBC adds one more layer.
The column is just "DATE". The same table has two "TIMESTAMPZ" columns to track record creation & modification that don't have this problem.
I know about the "slow" ODBC. That is why I very rarely use it. It is often my last resort if nothing else exists/works.
Isn't Zeos the fastest method for accessing external databases? I've been using it since my Delphi days and it is one of the first things I install in Lazarus/FPC. It has always been very reliable.
The last time I had a problem with it was in 2016 https://zeoslib.sourceforge.io/viewtopi … 40&t=41785 (due to my inexperience with PostgreSQL back then when switching from Firebird) and curiously it was SynDBPostgres that saved the day back then too.
This time I think I will keep Zeos & SynDBPostgres options going forward.
Do you think I should post this problem on the Zeos forums also or is it unnecessary since EgonHugeist is here as well?
Thanks,
JD
ODBC is proving a pain to set up. Is what I've done below correct because my mORMot server refuses to start after I compile?
// https://www.connectionstrings.com/postgresql-odbc-driver-psqlodbc/
// Driver={PostgreSQL UNICODE};Server=IP address;Port=5432;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
fDbProps := TODBCConnectionProperties.Create('','Driver=PostgreSQL Unicode'+
{$ifdef CPU64}'(x64)'+{$endif}';Database=testdb;'+
'Server=localhost;Port=5432;UID=testdb;Pwd=testpwd','','');
// To prevent PostgreSQL from hitting the default maximum connection limit of 100
// and after rejecting subsequent connections
TODBCConnectionProperties(fDbProps).ThreadingMode := tmMainConnection;
Thanks
JD
What is the type of date_sanction columnus in database? Is SynDBPostgres works as expected ?
The "date_sanction" column is a simple date column.
I just tested SynDBPostgres and it works as expected. All dates were in the JSON result.
But soon as I changed back to a Zeos connection, I lost all but the first date. So the problem may be from Zeos.
I will try ODBC as soon as I can and report my findings.
JD
Which database are you using?
Did you try with another provider (e.g. ODBC)?
PostgreSQL 11.7 and I have not tried ODBC yet. I will do so and let you know my findings.
Hi there everyone,
I just noticed a wierd behavior relating to dates with the FetchAllAsJson function. When I run a query I get a JSON array result where only the first object has dates. All the other objects have empty date values. Here is a sample JSON result I got from my query.
{
"result": [
[
{
"numero_sanction": 5,
"numero_accueilli": 43,
"date_sanction": "2019-07-07",
"type_sanction": "Avertissement écrit",
},
{
"numero_sanction": 4,
"numero_accueilli": 43,
"date_sanction": "",
"type_sanction": "Mise à pied",
},
{
"numero_sanction": 1,
"numero_accueilli": 23,
"date_sanction": "",
"type_sanction": "Avertissement écrit",
},
{
"numero_sanction": 2,
"numero_accueilli": 23,
"date_sanction": "",
"type_sanction": "Avertissement écrit",
},
{
"numero_sanction": 3,
"numero_accueilli": 23,
"date_sanction": "",
"type_sanction": "Avertissement écrit",
}
]
],
"id": 9
}
This is not correct because it is impossible to save the records without a valid date. This was confirmed when I queried the PostgreSQL 11.7 database directly getting the expected result below:
numero_sanction|numero_accueilli|date_sanction|type_sanction |
---------------|----------------|-------------|-------------------|
5| 43| 2019-07-07|Avertissement écrit|
4| 43| 2020-01-21|Mise à pied |
1| 23| 2018-03-21|Avertissement écrit|
3| 23| 2018-08-28|Avertissement écrit|
2| 23| 2018-08-28|Avertissement écrit|
This is the same for all my queries not just this one and this behaviour is recent. It was never like this before. I don't know if the problem is from mORMot or from ZeosLib.
Any assistance with resolving this problem will be appreciated.
Thanks,
JD
Hi there ab,
Sorry for the late reply. I have to apologize because I found the cause of the problem. It was a compiler directive that I disabled and had forgotten about in one of the source files. The end result was that the client and server were not using the same protocols. Everything now works perfectly.
Thank you very much for your time and for the suggestions you gave me.
JD
Here are the Heaptrc dump images from the server
Did you try to disable Compression := [hcSynShaAes] ?
I just tried it. It did not work either. Can I upload the Heaptrc dump images? There are just 2 of them.
JD
Hi ab,
This is what I did
fHTTPServer := TSQLHttpServer.Create(AnsiString(fServerSettings.Port), [fRestServer], '+', {HTTP_DEFAULT_MODE} useHttpSocket, 32, TSQLHttpServerSecurity.secSynShaAes);
THttpServer(fHTTPServer.HttpServer).WaitStarted();
It didn't work.
I can call my interface based services using my browser or an application like Postman but I can no longer connect to the server using a Lazarus client. This is what was happening even before the addition of THttpServer.WaitStarted.
JD
Hi there ab,
I ran TestSQL3 and some assertions failed. Here are the relevant messages:
1.2. Low level types:
- RTTI: 1,340 assertions passed 1.71ms
- Url encoding: 200 assertions passed 1.31ms
- Encode decode JSON: 429,322 assertions passed 2.47s
- Wiki markdown to html: 56 assertions passed 492us
- Variants: 88 assertions passed 386us
- Mustache renderer: 153 assertions passed 1.03s
- TDocVariant: 91,785 assertions passed 235.03ms
! - TDecimal128: 22 / 17,446 FAILED 21.26ms
- BSON: 245,068 assertions passed 18.98ms
100000 TBSONObjectID.ComputeNew in 8.79ms i.e. 11,372,682/s, aver. 0us
- TSynTableStatement: 221 assertions passed 8.40ms
- TSynMonitorUsage: 1,202 assertions passed 3.26ms
Total failed: 22 / 786,881 - Low level types FAILED 3.82s
.........
.........
Windows 10 64bit (10.0.18363) (cp1252)
4 x Intel(R) Core(TM) i3-3240 CPU @ 3.40GHz (x86)
Using mORMot 1.18.5960
TSQLite3LibraryStatic 3.31.0 with internal MM
Generated with: Free Pascal 3.2 32 bit compiler
Time elapsed for all tests: 3m25
Performed 2020-04-23 00:26:57 by JD on DESKTOP-NPLKN1D
Total assertions failed for all test suits: 22 / 44,408,725
! Some tests FAILED: please correct the code.
JD
Hi there everyone,
I just updated to the latest version of mORMot dated 22/04/2020. I recompiled my principal mORMot project and to my surprise, I can no longer connect to the Lazarus server from a Lazarus client.
My code is as follows:
Client side:
fClient := TSQLHttpClient.Create(AnsiString(fClientSettings.HostOrIP), AnsiString(fClientSettings.Port), fModel, false, '', '', fConnectionSettings.SendTimeout, fConnectionSettings.ReceiveTimeout, fConnectionSettings.ConnectTimeout);
TSQLHttpClient(fClient).Compression := [hcSynShaAes];
The values above are:
fConnectionSettings.SendTimeout = 15000
fConnectionSettings.ReceiveTimeout = 15000
fConnectionSettings.ConnectTimeout = 20000
Server side:
fHTTPServer := TSQLHttpServer.Create(AnsiString(fServerSettings.Port), [fRestServer], '+', {HTTP_DEFAULT_MODE} useHttpSocket, 32, TSQLHttpServerSecurity.secSynShaAes);
THttpServer(fHTTPServer.HttpServer).ServerKeepAliveTimeOut := CONNECTION_TIMEOUT;
This code works perfectly with older versions of mORMot. It is patterned after the example of George, in the list of mORMot examples. I have no idea why it no longer works.
I would appreciate any help in the resolution of this problem.
By the way, I am using Lazarus 2.1/fpc 3.2 rc1 Win32.
Cheers,
JD
Thanks a lot everyone. It worked.
JD
Hi there everyone,
I just updated my mORMot version yesterday (19/04/2020) & I want to upgrade my two projects using mORMot. However as I tried to recompile one of the projects, I got an error in the SynDBZeos file on line 886 saying Error: identifier idents no member "StartTransaction". The compilation messages relating to only SynDBZeos.pas are shown below:
.....
.....
SynDBZeos.pas(707,30) Hint: Variable "Tables" of a managed type does not seem to be initialized
SynDBZeos.pas(734,64) Hint: Variable "Fields" of a managed type does not seem to be initialized
SynDBZeos.pas(886,13) Error: identifier idents no member "StartTransaction"
SynDBZeos.pas(962,17) Hint: Local variable "ndx" does not seem to be initialized
Any ideas what I can do to correct this problem?
Thanks a lot in advance for your assistance
JD
PS: I am using Lazarus 2.0.7/fpc 3.2 svn 62681 (Win 32) on Windows 10 Professionnal (x64)
Thanks a lot for the tip Esteban. It works properly now.
JD