#302 Re: mORMot 1 » mORMot 2 - Project05HttpDaemon 64bit Error » 2022-10-26 07:58:39

Clean from github, last commit + the code you requested above
Alexandria 11.2 patch1
Only added win64 target

https://gist.github.com/dkounal/63adc5a … 01c26c29a9

#304 Re: mORMot 1 » mORMot 2 - Project05HttpDaemon 64bit Error » 2022-10-24 17:03:52

I tried it the weekend and I noticed that it creates an exception when trying to create the service
mormot.core.windows.inc

function TServiceController.Start(const Args: array of PChar): boolean;
begin
  if length(Args) = 0 then
    result := StartService(fHandle, 0, nil)
  else
    result := StartService(fHandle, length(Args), @Args[0]);
end;

tried admin account, same problem

#305 Re: mORMot 1 » parameter in the beginning of sql query and exception: zeos or mormot? » 2022-10-24 16:46:53

ab wrote:

From TSqlDBStatement.ExecutePreparedAndFetchAllAsJson ?

In TSqlDBZeosStatement.ExecutePrepared from mormot.db.sql.zeos the fStatement.GetSQL returns the correct query:

select pid as ID from table where am=? limit 1

#306 Re: mORMot 1 » parameter in the beginning of sql query and exception: zeos or mormot? » 2022-10-24 06:30:48

Problem found again today. From logs it happens after mormot2 enters zeos' pas units, after exceptions to other sql queries and probably due to the sqlwriter that creates the query for zeos.
Reported to zeos forum and waiting approval. To be honest, I feel uncertain using zeos for the future.
I transformed most insert queries to Trestbatch where insert ignore is available. Anyway time penalty with memberexists is the same.

#307 Re: mORMot 1 » parameter in the beginning of sql query and exception: zeos or mormot? » 2022-10-22 16:40:08

ab wrote:

AcquireExecutionMode[] is for remote REST access, not direct IRestOrm access.

Ok I will remove it. I noticed that it is needed if TSQLDBZEOSConnectionProperties.ConnectionTimeOutMinutes is set.

// - warning: no connection shall still be used on the background (e.g. in
    // multi-threaded applications), or some unexpected issues may occur - for
    // instance, ensure that your mORMot ORM server runs all its statements in
    // blocking mode for both read and write:
    // ! aServer.AcquireExecutionMode[execOrmGet] := am***;
    // ! aServer.AcquireExecutionMode[execOrmWrite] := am***;
    // here, safe blocking am*** modes are any mode but amUnlocked, i.e. either
    // amLocked, amBackgroundThread or amMainThread
    property ConnectionTimeOutMinutes: cardinal
      read GetConnectionTimeOutMinutes write SetConnectionTimeOutMinutes;

ab wrote:

OneFieldValue() does not use the WriteLock.

Sure, I have not this error the last two days since I put a WriteLock in an other place of my program where multiple threads could try at the same time to add in an other table the same row info.
Looking in orm.add I noticed that it has a lock, why a WriteLock for an orm.add stopped this error?

#308 Re: mORMot 1 » parameter in the beginning of sql query and exception: zeos or mormot? » 2022-10-22 09:31:09

Finally Orm.WriteLock/WriteUnLock when used in other parts of my program when multiple threads call add in the same table probably the same record (same IDValue). I also defined the ZEOS_DISABLE_POOLED directive in zeoslib
Just wondering why the following lock that exists in Orm.InternalAdd does not help and I have to use Orm.WriteLock/WriteUnLock

  fRest.AcquireExecution[execOrmWrite].Safe.Lock;
  try
    // may be within a batch in another thread -> use execOrmWrite lock
    result := EngineAdd(t, json); // will call static if necessary
  finally
    fRest.AcquireExecution[execOrmWrite].Safe.UnLock;
  end;

I am using Mariadb with

AcquireExecutionMode[execOrmGet]:=amBackgroundThread;
AcquireExecutionMode[execOrmWrite]:=amBackgroundThread;

#309 Re: mORMot 1 » memberexists does not help » 2022-10-21 10:53:32

ab wrote:

Note that insert/or/ignore is not exactly the same as update/or/insert.

Take a look at EncodeInsertPrefix() in mormot.db.core.pas.
We did not include Oracle yet because it is very complicated to get it working properly. As often with Oracle.
And PostgreSQL also expect a complex syntax with the column names to ignore, as On CONFLICT(column1, ....) DO NOTHING;.

I am not familiar with Oracle and Firebird
Firebird,  Oracle, Postgres do not have an 'INSERT [OR] IGNORE' dialect

For Oracle I have included the info

For firebird >2.1 is just a little more complex (you have to provide the unique indexes) as described here:
https://firebirdsql.org/refdocs/langref … nsert.html

For postgres  >9.5 nearly the same with firebird
INSERT INTO table(column1, column2, ...)
VALUES
  (value1, value2, ....),
  (value1, value2, ....)
On CONFLICT[(column1, ....)] DO NOTHING;
https://www.postgresql.org/docs/10/sql-insert.html

#310 Re: mORMot 1 » memberexists does not help » 2022-10-21 09:21:33

From a small search, INSERT IGNORE is supported by SQLITE, postgres, Oracle, mysql, mariadb,firebird
SQLITE,mysql : INSERT IGNORE
Oracle: INSERT .... IGNORE_ROW_ON_DUPKEY_INDEX
Firebird: UPDATE OR INSERT

For Oracle there is enough info:
https://blogs.oracle.com/sql/post/how-t … e-database
http://guyharrison.squarespace.com/blog … -hint.html (old article)

#311 Re: mORMot 1 » memberexists does not help » 2022-10-21 08:14:54

Thank you a lot @ab
check also the above discussion
Probably adding ignore to INSERT is a better approach

#312 Re: mORMot 1 » memberexists does not help » 2022-10-21 07:35:28

Reading the following response from overflow:


REPLACE INTO table(column_list) VALUES(value_list);

is a shorter form of

INSERT OR REPLACE INTO table(column_list) VALUES(value_list);

For REPLACE to execute correctly your table structure must have unique rows, whether a simple primary key or a unique index.

REPLACE deletes, then INSERTs the record and will cause an INSERT Trigger to execute if you have them setup. If you have a trigger on INSERT, you may encounter issues.

This is a work around.. not checked the speed..

INSERT OR IGNORE INTO table (column_list) VALUES(value_list);

followed by

UPDATE table SET field=value,field2=value WHERE uniqueid='uniquevalue'

This method allows a replace to occur without causing a trigger.

Probably an insertOrIgnore (or an extra boolean flag in add to add 'or ignore') is better for this case and it is supported by sqlite

#313 Re: mORMot 1 » memberexists does not help » 2022-10-21 07:30:55

Thank you @ab. Please try to have a replace function as we have  add/update for ORM

An other question:
If I use a batch, how can I add to the batch a sql command for multiple rows like the following:

update table set act=0

Thank you in advance

#314 mORMot 1 » memberexists does not help » 2022-10-20 18:32:58

dcoun
Replies: 8
var b:boolean;
      o:TOrmamyclass;
......
 if srv.Orm.MemberExists(TOrmamyclass,o.IDValue) then b:=srv.Orm.Update(o) else b:=srv.Orm.Add(o,true,true)=o.IDValue;

The above does not work all the times, I am getting:

Exception: 20221020 16294225  " EXC   EZSQLException {Message:"SQL Error: Duplicate entry '1611284410' for key 'PRIMARY' \r\nCode: 1062 SQL: insert into amyclass (bid,xml,stat) values (?,?,?)"} [Pool7-TEpresslave] at 0235e59a ZDbcMySql.pas TZMySQLConnection.HandleErrorOrWarning (1271)  ZDbcMySql.pas TZMySQLConnection.HandleErrorOrWarning (1271) ZDbcMySqlStatement.pas TZAbstractMySQLPreparedStatement.ExecuteUpdatePrepared (1150) mormot.db.sql.zeos.pas TSqlDBZeosStatement.ExecutePrepared (1204) mormot.orm.sql.pas TRestStorageExternal.ExecuteFromJson (2096) mormot.orm.sql.pas TRestStorageExternal.EngineAdd (1249) mormot.orm.rest.pas TRestOrm.Add (1725) .........

There are not many threads that try to write the same thing
Without ORM I used to have a REPLACE sql command. Now what to do?
After the above, everything goes out of control with "Commands out of sync" and that generally happens if such an error (duplicate primary key or field out of range) happens
Delphi 11.2 win32

#315 Re: mORMot 1 » parameter in the beginning of sql query and exception: zeos or mormot? » 2022-10-12 16:44:27

ab wrote:

The log states SQL: select ID from apimans where am=? limit 1" in the 3rd line, which seems correct.

Try
1. to add some logs to see what is actually executed.
2. to add some critical section lock/unlock around the ORM call to see if there is a multi-thread problem.
3. to ask also from help on the Zeos support forum.

can you help me a bit about the 2?
It runs in threads. What is the orm calls what should be protected more with a critical section? Should I use the orm.Writelock/orm.writeunlock for each Insert/update/delete sql command?
Thank you in advace

#316 mORMot 1 » parameter in the beginning of sql query and exception: zeos or mormot? » 2022-10-12 14:51:31

dcoun
Replies: 11

Running the following

DBsrvPool.GetDBsrv.Orm.OneFieldValue(TOrmapimans,'RowID','am=:('+inttostr(am)+'):')

Sometimes, I get sometimes the following error:

Exception: 20221011 18040212  ) EXC   EZSQLException {Message:"
SQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version 
for the right syntax to use near '13100000113select ID from apimans where am=? limit 1' at line 1 \r\nCode: 1064 
SQL: select ID from apimans where am=? limit 1"} [] at 01ccb696 
ZDbcMySql.pas TZMySQLConnection.HandleErrorOrWarning (1271)  
ZDbcMySql.pas TZMySQLConnection.HandleErrorOrWarning (1271) 
ZDbcMySqlStatement.pas ExecuteEmulated (1039) 
ZDbcMySqlStatement.pas TZAbstractMySQLPreparedStatement.ExecuteQueryPrepared (1051) 
mormot.db.sql.zeos.pas TSqlDBZeosStatement.ExecutePrepared (1179) 
mormot.db.sql.pas TSqlDBStatement.ExecutePreparedAndFetchAllAsJson (6664) 
mormot.orm.sql.pas TRestStorageExternal.EngineList (1380) 
mormot.orm.server.pas TRestOrmServer.EngineList (1073) 
mormot.orm.rest.pas TRestOrm.ExecuteList (1675) 
mormot.orm.rest.pas TRestOrm.MultiFieldValue (976) 

As you can notice the parameter is in the beginning of the sql query. Is it Mormot's fault or Zeos's?

I am using Mormot2, Delphi 11.2 and Zeoslib 8.0-patches from github

#318 Re: mORMot 1 » PopHead in TDynArray will try finalize an 'object' if is not null » 2022-10-09 19:13:11

The definition is:

lowr:ilist<TepGenericSlave>;

The creation is:

lowr:=Collections.NewList<TepGenericSlave>;

The pop is used like the following and produces exceptions:

TepGenericSlave=class
....

obj:=TepGenericSlave.create;
...
repeat
...
lowr.Pop(obj,[popFromHead]);
...
until ....;

The pop is used like the following and does not produce exceptions:

TepGenericSlave=class
....

obj:=TepGenericSlave.create;
...
repeat
...
obj:=nil;
lowr.Pop(obj,[popFromHead]);
...
until ....;

#319 mORMot 1 » PopHead in TDynArray will try finalize an 'object' if is not null » 2022-10-09 16:16:58

dcoun
Replies: 4

I was getting random exceptions from an ilist with objects
The exception is coming from mormot.core.data line 6988 (fInfo.ArrayRtti.ValueFinalize)

procedure TDynArray.ItemMoveTo(index: PtrInt; Dest: pointer);
var
  p: pointer;
begin
  p := ItemPtr(index);
  if (p = nil) or
     (Dest = nil) then
    exit;
  if (fInfo.ArrayRtti <> nil) and
     not fNoFinalize then
    fInfo.ArrayRtti.ValueFinalize(Dest); // also handle T*ObjArray
  MoveFast(p^, Dest^, fInfo.Cache.ItemSize);
  FillCharFast(p^, fInfo.Cache.ItemSize, 0);
end;

which is called by same unit, line 6858

function TDynArray.PopHead(var Dest): boolean;
begin
  result := GetCount <> 0;
  if result then
  begin
    ItemMoveTo(0, @Dest);
    Delete(0);
  end;
end;

The problem was that the object variable passed to pophead was not null and before poping the new object  ItemMoveTo try to finalize it.
probably adding a Dest:=nil; somewhere before ItemMove in PopHead?
Or, probably adding this requirement (dest must be nil) in Pop's documentation?

#320 Re: mORMot 1 » Delphi FMX Android client? » 2022-10-05 08:59:19

ab wrote:

My CE license expired a few years ago, and I failed to renew it.
EMB licensing is a real PITA.

And IIRC 10.4 had no shortstring support.

shortstring was renabled in 10.4
CE license can not be renewd from what I read, you have right they are problematic.
You uninstall it and you reinstall it with registry cleared

#321 Re: mORMot 1 » Delphi FMX Android client? » 2022-10-05 06:43:56

ab wrote:

It is difficult to me to help without a proper Delphi compiler...

sad

Delphi 10.4 community edition is free for not commercial purposes
Its android version is a bit old but only google playstore rejects its executables, you can test it in devices+emulators+amazon playstore+windows 11

#323 Re: mORMot 1 » Delphi FMX Android client? » 2022-09-28 21:51:43

ab wrote:

Main mORMot 2 units have no Delphi Android/iOS/Linux support yet.
But in mORMot 2, it could be easier to do, since almost all OS specific code is within mormot.core.os.pas. So any input is welcome.

Probably I am not adding anything new, but, mormot.core.base can not be compiled and has no further dependencies

#324 Re: mORMot 1 » Is there a different timeout when calling an interface procedure? » 2022-09-24 18:05:07

Just an other problem with RetrieveListJson and LIMIT/OFFSET
I am running the following command:

srvdb.Orm.RetrieveListJson(TormRepErrors,'dat > :(20220913): AND dat < :(20220925): ORDER BY dat DESC LIMIT 20 OFFSET 0',[],'*');

The query returned by mormot.orm.sql 's TRestStorageExternal.AdaptSqlForEngineList(var SQL: RawUtf8): boolean; is

select ID,dat,typ,mid,termnam,mariadbver,pchrver,user_ as user,ctid,app,uid,dver,build,msg from reperrors where dat>:(20220913): and dat<:(20220925): order by dat desc limit 20

The next page will be retrieved with

srvdb.Orm.RetrieveListJson(TormRepErrors,'dat > :(20220913): AND dat < :(20220925): ORDER BY dat DESC LIMIT 20 OFFSET 20',[],'*');

But now the query returned by mormot.orm.sql 's TRestStorageExternal.AdaptSqlForEngineList(var SQL: RawUtf8): boolean; is

SELECT RowID,dat,typ,mid,termnam,mariadbver,pchrver,user,ctid,app,uid,dver,build,msg FROM RepErrors WHERE dat > :(20220913): AND dat < :(20220925): ORDER BY dat DESC LIMIT 20 OFFSET 20

Can you notice that the first return is "ID" but in the second it is returning a "RowID"? it seems that in the second, it does not "touch" the initial query.
The problem is that resulting JSON has different the first field if searched by name

#325 Re: mORMot 1 » Is there a different timeout when calling an interface procedure? » 2022-09-24 17:05:59

So, no exception now and it works
I will try it again now with websockets.
I noticed that you are doing an excellent work with Letsencrypt. When will it be ready to test it?
as alternate what is the correct configuration in nginx  for using >100 clients with websockets behind nginx?

#326 Re: mORMot 1 » Is there a different timeout when calling an interface procedure? » 2022-09-24 16:50:09

ab wrote:

Limit 0,20 is a valid MySQL syntax...

I think it is for sqlite also
https://www.sqlite.org/lang_select.html

It needs it as 20,0 and mormot is too clever....I think
Thanks a lot again @ab

#327 Re: mORMot 1 » Is there a different timeout when calling an interface procedure? » 2022-09-24 15:07:55

The problem for the limit is in mormot.db.core, constructor TSelectStatement.Create(const SQL: RawUtf8; const GetFieldIndex: TOnGetFieldIndex; const SimpleFields: TSelectStatementSelectDynArray);

called by mormot.orm.sql 's TRestStorageExternal.AdaptSqlForEngineList(var SQL: RawUtf8): boolean;

it returns the limit=0 in the following query

'SELECT RowID,dat,typ,mid,termnam,mariadbver,pchrver,user,ctid,app,uid,dver,build,msg FROM RepErrors WHERE dat > :(20220913): AND dat < :(20220925): ORDER BY dat DESC Limit 0,20'

How is your service implemented?

Help me with what information you need..

#328 Re: mORMot 1 » Is there a different timeout when calling an interface procedure? » 2022-09-24 14:34:10

Starting from the end:
network is not slow. the 29sec shown by HeidiSQL is the time needed by mysql_store_result as shown here: https://www.heidisql.com/forum.php?t=36841
Mormot2 seems to need at least the half time. But it is a table which could have 1 million inserts every 12h

I tried to find in the log that they are connected with the request. How can I identify the line that has to do with SQLite3 virtual table?
I will try to debug it in delphi.

#329 Re: mORMot 1 » Is there a different timeout when calling an interface procedure? » 2022-09-24 11:13:49

To be honest I was a bit lost in logs in the server. After that I setup the service to include threadid, to flush every second and I disabled the upgrade to websockets in client.
Now the client hangs till the timeout of 30seconds (it was probably the websocket upgrade) and as you proposed in such a case it will be better to create a thread and return result with websocket response.
But the first problem was that with websocket in 4-5 seconds the request was finished with timeout (probably due to the following exception).

The other interesting point is that the LIMIT keyword part in the sql query is missing (I had it in FormatSqlWhere) when executing RetrieveListJson, so the returned data was much more than expected without paging.
The result is an exception due to big number of returned resutls that caused the extreme load....

See the logs in the https://gist.github.com/dkounal/1d32fda … ca06a84362

Running the query from HeidiSQL I got the following

/* Affected rows: 0  Found rows: 734.492  Warnings: 0  Duration for 1 query: 0,453 sec. (+ 29,047 sec. network) */

So, when LIMIT is allowed and which alternate to RetrieveListJson do you recommend to have paging in results?
Thank you in advance

#330 Re: mORMot 1 » Is there a different timeout when calling an interface procedure? » 2022-09-23 18:52:37

The client gives the following:

20220923 18480812  -    00.092.557
20220923 18480949  +    mormot.soa.client.TServiceFactoryClient(07f13f70).InternalInvoke IwbService.repsearch("{\"mver\":-1,\"typ\":-1,\"user\":-1,\"pver\":-1,\"tofind\":\"\",\"term\":-1,\"sdat\":\"2022-09-13\",\"edat\":\"2022-09-23\"}",0,20) 
20220923 18480949  +    	mormot.rest.http.client.TRestHttpClientWebsockets(07db7a80).InternalUri POST
20220923 18480949 trace 		mormot.rest.http.client.TRestHttpClientWebsockets(07db7a80) InternalRequest POST calling THttpClientWebSockets(07db7840).Request
20220923 18480949 trace 		mormot.net.ws.client.TWebSocketProcessClient(07d20b20) NotifyCallback(central/v1/wbService.repsearch,wscBlockWithAnswer)
20220923 18480949 trace 		mormot.net.ws.client.TWebSocketProcessClient(07d20b20) SendFrame host.domain.info r000007 focBinary len=404
20220923 18481505 warn  		mormot.net.ws.client.TWebSocketProcessClient(07d20b20) NotifyCallback TIMEOUT a000007
20220923 18481505 clnt  		mormot.rest.http.client.TRestHttpClientWebsockets(07db7a80) POST central/v1/wbService.repsearch status=404 len=0 state=0
20220923 18481505  -    	05.296.380
20220923 18481505 trace 	mormot.rest.http.client.TRestHttpClientWebsockets(07db7a80) POST central/v1/wbService.repsearch returned 404 (Not Found) with message Not Found

#331 Re: mORMot 1 » Is there a different timeout when calling an interface procedure? » 2022-09-23 18:44:34

The problem is on the server. The cpu load goes to the sky and I have no logs due to delayed write. I will check to find the option to write at once the logs. Thank you

#332 mORMot 1 » Is there a different timeout when calling an interface procedure? » 2022-09-23 13:40:07

dcoun
Replies: 13

Using Delphi 11.1 I have a TRestHttpClient from mormot2 created with 30000msec timeount to connect to a mormot2 server in Linux compiled with FPC and call an interface.
The procedure of the interface called in the server, runs a query using a RetrieveListJson and it returns in 4-6 sec with the following error:

Project ErrorViewer.exe raised exception class EInterfaceFactory with message 'TInterfacedObjectFakeClient.FakeCall(IwbService.repsearch) failed: 'URI central/v1/wbService.repsearch ["{\"mver\":-1,\"typ\":-1,\"user\":-1,\"pver\":-1,\"tofind\":\"\",\"term\":-1,\"sdat\":\"2022-09-13\",\"edat\":\"2022-09-23\"}",0,20] returned status 'Not Found' (404 - Network problem or request timeout)''.

Probably the query needs more time or the database that gets a lot of inserts per minute could not respond fast. But it seems to be from the client side and the timeout of 30.000msec for the three constructor's arguments is not taken into account. I have also added a "timeout=30" to ZEOS options during connection without success

Can you think a possible cause?
Thank you in advance

#334 Re: mORMot 1 » Wrong field type in Mariadb if compressed (FROM ZEOS DBc) » 2022-09-16 07:36:02

I was just to write it. Mormot2 depends on ZEOS for that
the problem is in line 714, of mormot.db.sql.zeos

      F.ColumnType := TZSQLTypeToTSqlDBFieldType(
        TZSQLType(res.GetInt(TableColColumnTypeIndex)));

in zdbintfs the res.GetInt returns wrong from zdbccache line 3001
thank you @ab

#335 Re: mORMot 1 » Wrong field type in Mariadb if compressed (FROM ZEOS DBc) » 2022-09-16 06:43:58

ab wrote:

What I don't understand is that TSqlDBConnectionProperties.ColumnTypeNativeToDB should call ColumnTypeNativeDefault.

Then 'longblob /*!100301 compressed*/' should be recognized as ftBlob since only the first chars are checked by IdemPPChar().

Could you debug and see why it is not the case?

TSqlDBConnectionProperties.ColumnTypeNativeToDB is never called

#336 Re: mORMot 1 » Wrong field type in Mariadb if compressed (FROM ZEOS DBc) » 2022-09-15 19:36:16

ab wrote:

So this "100301 compressed" tag comes from the data provider itself.
Where is the actual problem (unit/method)?

In mormot2, longblob database field should have Columntype in TRestStorageExternal.fFieldsExternal  as ftBlob, but as you can see in the code above, with this tag mormot2 has filled the longblob field's TSqlDBColumnDefine as int64 and Mormot2 can not save its contents in the database.

ab wrote:

Which way to you use to connect to MariaDB: ODBC? ZDBC? something else?

ZeosDBC 8.0-patches from github

#337 mORMot 1 » Wrong field type in Mariadb if compressed (FROM ZEOS DBc) » 2022-09-15 13:24:13

dcoun
Replies: 8

Trying to save a blob in a TOrm object I arrived with a row in database where the blob content was '0'
Trying to debug it I noticed that fFieldsExternal in TRestStorageExternal was defined as follows:

(('id', 'int', 11, 11, 0, ftInt64, True), ('img', 'longblob /*!100301 compressed*/', 0, 0, 0, ftInt64, False))

This comment in field type as returned by the database because the field is automatically compressed by the database causes the trouble and defined it as ftInt64 instead of ftBlob
It is possible to ignore the comments in the definition in order not to have this trouble?
Thank you in advance

#338 mORMot 1 » How to set a JWT Bearer in TRestHttpClientWinHttp » 2022-09-01 14:56:01

dcoun
Replies: 0

It took me some time to debug it and find why I got denials when using a TRestHttpClientWinHttp to authenticate using JWTs

In the following code gives back error that JWT is not provided :

cl:=TRestHttpClientWinHttp.Create(SrvIP,inttostr(SrvPort),TOrmModel.Create([],urlbase),SrvSsl,'','',netsendTimeout,netretTimeout,netsendTimeout);
cl.Model.Owner:=cl; 
if cl.ServerTimestampSynchronize then 
begin
cl.CustomHeader:=AuthorizationBearer(TheJWThere);
if cl.ServiceDefine([iservice],sicShared) then cl.Resolve(iservice,serv);
end;

Instead of the following

cl.CustomHeader:=AuthorizationBearer(TheJWThere);

use the following:

cl.SessionHttpHeader:=AuthorizationBearer(TheJWThere);

it seems that cl.CustomHeader is not sent to the server

#339 Re: mORMot 1 » Is a Tdate property allowed in a TOrm object? » 2022-08-31 17:44:34

ab wrote:

Did you try with TDateTime?

With Tdatetime, as I wrote, there is no problem

#340 mORMot 1 » Is a Tdate property allowed in a TOrm object? » 2022-08-30 22:16:05

dcoun
Replies: 3

I just notice that if a TOrm derived object has a property of type Tdate then when adding-saving it in the database (mariadb) through zeos I am getting crazy dates in the future.
For example 21-07-1975 is transformed in the insert query as '2759-01-01'
If I change the property to Tdatetime type, the date in the sql query is shown ok ('1975-07-21')
In the database it is created as Date field.

I noticed that in TOrm.AppendAsJsonObject a Tdatetime property is going through TOrmPropInfoRttiDateTime.GetJsonValues and TTextDateWriter.AddDateTime.  In contrast, a Tdate property is going through TOrmPropInfoRttiDouble.GetJsonValues

Are Tdate type valid for Torm properties?

Thank you in advance

#342 Re: mORMot 1 » websocket client does not get reponse if slashes exist » 2022-08-21 08:40:24

ab wrote:

Did you debug a little more to find out why and propose a pull request to fix it?

The problem is in mormot.rest.client, line 2347

The following works for me, but I am sure what you believe it is the best approach

  i:=Length(fModel.Root);
  root:=Copy(url,1,i);
  Split(Copy(url,i+2,4096), '/', interfmethod, id);

url ,root variable are not needed any more (a delete could be more efficient) but do you need them for cleaner code?

#343 Re: mORMot 1 » websocket client does not get reponse if slashes exist » 2022-08-20 17:08:47

ab wrote:

So it works?

No. It does NOT work

As shown above procedure TLongWorkCallback.WorkFinished never get called

#344 Re: mORMot 1 » websocket client does not get reponse if slashes exist » 2022-08-20 14:48:27

Trying examples from mormot2/ex/rest-websockets
Running restws_longworkserver and restws_longworkclient as it is in repository
Received the following in the client

Service.TotalWorkCount=1
>20220820 14403901  " trace mormot.net.ws.client.TWebSocketProcessClient(053b4458) GetFrame  frames focBinary len=102
20220820 14403901  " trace mormot.net.ws.client.TWebSocketProcessClient(053b4458) GetSubFrame(1/2)  r000001 focBinary len=63
Received callback WorkFinished(help) in 5047ms
>20220820 14403901  " trace mormot.net.ws.client.TWebSocketProcessClient(053b4458) GetSubFrame(2/2)  r000002 focBinary len=29

Now in line 106,in the server

  Server := TRestServerFullMemory.CreateWithOwnModel([],False,'root/test');

and in line 98 in the client

        Client := TRestHttpClientWebsockets.Create('127.0.0.1', '8888', TOrmModel.Create([],'root/test'),false,'','',0,0,2000);

Running them and the response in the client it is now:

Service.TotalWorkCount=1
>20220820 14424803  " trace mormot.net.ws.client.TWebSocketProcessClient(04944458) GetFrame  frames focBinary len=131
20220820 14424803  " trace mormot.net.ws.client.TWebSocketProcessClient(04944458) GetSubFrame(1/2)  r000001 focBinary len=87
20220820 14424803  " trace mormot.net.ws.client.TWebSocketProcessClient(04944458) GetSubFrame(2/2)  r000002 focBinary len=34

both compiled with delphi 11.1

#345 Re: mORMot 1 » websocket client does not get reponse if slashes exist » 2022-08-20 14:05:55

ab wrote:

I don't see where the '/' is not supported.
Do you have any hint?

The same project with websocket server and client works OK if no slash exists in the URI in model's creation.
if a slash exists, REST works ok, but the client never receives the websocket responses from the server

#346 mORMot 1 » websocket client does not get reponse if slashes exist » 2022-08-19 07:42:49

dcoun
Replies: 9

I have copied an existing working skeleton of a websocket client/server example I have made for my work
The copied project had one major problem:
Websocket client connects, it does everything ) need as rest client, it does not disconnect but it never gets a websocket response through the callback interface (more or less the same with the existing sample in Mormot1)
After spending a couple of hours to find what happens, I found the problem:
The orm model (used by trestserver and TRestHttpClientWebsockets) is created with a url base that contains a slash like 'base1/subbase2'
if this slash is missing, everything is ok
Is it my fault, or is it a bug?

To describe it better, I wanted to have one base 'urlbase' and two different Trestservers after that, one with authentication ('/urlbase/main') and the other without ('/urlbase/auth').
Is it possible to have a base url for the TRestHttpServer and each Trestrerver after this base url?

#348 mORMot 1 » JWT authentication for selected interfaces » 2022-08-17 20:31:07

dcoun
Replies: 2

Is it possible in a TRestServer to have 2 interfaces and to enable JWT checking only for the one interface?
I can set the JwtForUnauthenticatedRequest in a Trestserver.
Using TServiceFactoryServerAbstract as returned by TRestServer.ServiceDefine has a lot of function for classic authentication but not for JWT

Also, an other question. How can I disable access to an interface from a http client if websocket connected is not upgraded and used?
Thank you in advance

#349 Re: mORMot 1 » REPLACE sql statement in REST » 2022-08-12 09:23:25

Trying to debug it, I noticed that in the update sql query no data are expected to be returned back. That is ok
But an update is not returning an error if the updated record does not exist
I am using ZEOS 8.0-patches branch from GitHub

I switched to your second suggestion that it is better I believe too
I issue an OneField requesting the RowID

function OneFieldValue(Table: TOrmClass; const FieldName: RawUtf8; WhereID: TID): RawUtf8;

Board footer

Powered by FluxBB