#151 Re: mORMot 1 » SQLite local TSQLRestClientDB demo » 2022-01-10 13:50:26

Sorry to write on a suck ten years old thread, but it will be easier to me to stumb on again, and i think it should pinned big_smile

Reading it again made me realized I took a bad direction on a feature of the software I am working on, even if I read ten times the doc since my first mORMot introduction.


bartmormot.png

#152 Re: mORMot 1 » Update to latest mORMot2 doesn't create External Tables » 2021-09-13 12:26:06

Ok, back from resto, I cloned mORMot2-3.35.5, compiled the project, and everything is working as expected.

Then I switched to mORMot-3.36.0, compiled the project, and it works as expected too ... externals tables are created.


So everything is working, sorry this post..  if someone has a hint on what could be happening.. like a MySQL cache "issue" or something do not hesitate to write a comments. Thanks.

PS: The only things I didn't tested it's to restart the database server.

#153 Re: mORMot 1 » Update to latest mORMot2 doesn't create External Tables » 2021-09-13 10:12:33

I think I am doing things as it should. To be honest, I just pulled mORMot2 and compiled.

Model:

function DataModel: TOrmModel;
begin
  Result := TOrmModel.Create([
      TOrmLprPlateRawData
    ], ROOT_NAME);
end;

Server Initialization:

  // get the shared data model
  fModel := DataModel;

  // use external database for all tables
  VirtualTableExternalRegisterAll(fModel, fProps);

  // create the main mORMot server with authentication required
  fRestServer := TRestServerDB.Create(fModel, 'vremotesagas.db', true);

  fHttpServer := TSQLHTTPServer.Create(PORT_NAME, [fRestServer], SERVER_URL, useBidirSocket, 32, secNone);
  fHttpServer.AccessControlAllowOrigin := '*'; // allow cross-site AJAX queries

  // create tables or fields if missing
  fRestServer.CreateMissingTables;

PS:  To explain the different table name between the two version, I renamed it on new version.


Edit:

Pastebin of the full start log of the server :  https://pastebin.com/jSgCvjWR

#154 mORMot 1 » Update to latest mORMot2 doesn't create External Tables » 2021-09-13 09:35:44

flydev
Replies: 3

Hi,

I updated my project to the latest mORMot2 with SQLite static libs 3.36 and the latest Zeos lib and it look like that External Tables are not created anymore, it's possible that I missed something between two updates of the framework, I didn't saw a note about that.

With VERBOSE logs enabled, when the server start (CreateMissingTable log line reduced) :

> Old version :

[...]

20210913 11135418 DB            mormot.orm.sqlite3.TRestOrmServerDB(02de2b80) CreateMissingTables on {"TSqlDatabase(0378b490)"}
20210913 11135418 DB            mormot.orm.sqlite3.TRestOrmServerDB(02de2b80) GetTables=["AuthGroup","AuthUser","PlateRawData"]
20210913 11135418  +            mormot.orm.sql.TRestStorageExternal(0344a720).Create TOrmPlateRawData
20210913 11135418 info                  mormot.orm.sql.TRestStorageExternal(0344a720) TOrmPlateRawData as PlateRawData {"TSqlDBZeosConnectionProperties(02d54ec0)":
{Engine:"SqlDBZeos",ServerName:"localhost",DatabaseNameSafe:"remotesagas",UserID:"foobar",Dbms:"dMySQL",DbmsEngineName:"MySQL",BatchSendingAbilities:["cCreate"],BatchMaxSentAtOnce:4096,LoggedSqlMaxSize:2048,UseCache:true,StatementMaxMemory:536870912,RollbackOnDisconnect:true,DateTimeFirstChar:84,DBMSName:"mysql"}} 
Server={"TRestOrmServerDB(02de2b80)":{StaticVirtualTableDirect:true,DB:{"TSqlDatabase(0378b490)":
{FileName:"vremotesagas.db",UseCache:true,UseCacheSize:16777216,CacheSize:10000,PageSize:4096,PageCount:22,FileSize:90112,Synchronous:"smFull",LockingMode:"lmNormal",OpenV2Flags:6,SQLite3Library:{"TSqlite3LibraryStatic(02d833a0)":{Version:"TSqlite3LibraryStatic 3.35.5 with internal MM"}}}}}}

[...]

20210913 11135419  +            mormot.db.sql.zeos TSqlDBZeosStatement.Step (1203)
Server is now running on mykingspark.fr:61337/root

> New Version

20210913 11130122 SQL           mormot.db.raw.sqlite3.TSqlDatabase(035fce30) 206us vremotesagas.db returned 14 rows SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%';
20210913 11130122 DB            mormot.orm.sqlite3.TRestOrmServerDB(02e32040) CreateMissingTables on {"TSqlDatabase(035fce30)"}
20210913 11130122 DB            mormot.orm.sqlite3.TRestOrmServerDB(02e32040) GetTables=["AuthGroup","AuthUser","LprPlateRawData"]
20210913 11130122 SQL           mormot.db.raw.sqlite3.TSqlDatabase(035fce30) 4us vremotesagas.db PRAGMA locking_mode=NORMAL; = true
20210913 11130122  -            00.000.278
20210913 11130124 info          Server is now running on localhost:61337/root

There is no errors in logs.

Statement "mormot.orm.sql.TRestStorageExternal(0344a720).Create TOrmPlateRawData" is missing on the log on new version.
Statement "mormot.db.sql.zeos TSqlDBZeosStatement.Step" is missing on the log on new version.


Any hint ?

#155 Re: mORMot 1 » Opening the SQLite db with an External tool » 2021-07-31 08:33:22

Ok thanks - your comment make things clearer.

I didn't checked my code source right now but I don't remember to have changed something after my own post, but opening the same db while reading your post :

Capture-d-cran-2021-07-31-102716.png

I will check if I changed something and will report here


PS: I dont mean there is a bug in mormot2, I am just trying to understand what's is going wink

#156 mORMot 1 » Opening the SQLite db with an External tool » 2021-07-30 08:12:11

flydev
Replies: 3

Hello,

Just to be clear, the project works - everything is fine.


I am used to explore the SQLIte database with SQLiteSpy, but this morning after an update of my mORMotClient unit and a compilation, when I open the DB with the tool (same with HeidiSQL) I have theses error, check the screenshot :

Capture-d-cran-2021-07-30-095907.png

Sorry to post that, I dont want to scracth my head for hours trying to understand the error - any idea guys ?

#157 Re: mORMot 1 » Count of Names/Values of TDocVariantData » 2021-07-30 08:03:19

Yes, you must use

TDocVariantData.Names._Count - 1

#158 Re: mORMot 1 » TTaskDialog in Mormot2 ? » 2021-06-07 09:17:45

wienani wrote:

Only TTaskDialog big_smile

And `mORMotUIEdit (mORMotUI*)` could be cool too cool

#159 Re: mORMot 1 » TSynLogPerThreadMode = ptIdentifiedInOnFile, 'File access denied'? » 2021-06-01 06:58:16

wxinix wrote:

But I do have a question - it seems that TSynLog cannot capture the StackOverFlow exception that happened in a background thread?

This might be due to OTL. Read this sentence about Exception notifications: http://www.omnithreadlibrary.com/book/chap14.html - then you can try to call your ILog.Log() mecanism inside your exception filter.

#160 Re: mORMot 1 » TSynLogPerThreadMode = ptIdentifiedInOnFile, 'File access denied'? » 2021-05-31 13:15:20

Just in case, read @ab's and @mpv's comment there :  https://synopse.info/forum/viewtopic.php?id=5793

I have also more than 80 clients with servers in production  (on mormot v2 now) and no TSynLog issue since months. I can remember having issue with TSynLog but it was my learning curve that was not completed, and the issue was introduced by me, it was also a bit hard to spot as I am mixing mORMot2 and OmniThreadLibrary.

#161 Re: mORMot 1 » TSQLHTTPServer, WebSockets and SSL » 2021-05-26 05:55:38

Thanks @ab, effectively, this is something I didn't think of.

#162 mORMot 1 » TSQLHTTPServer, WebSockets and SSL » 2021-05-25 10:08:59

flydev
Replies: 2

Hi everyone,

I am maybe starting a dumb question, it's possible to have a TSQLHTTPServer running with useBidirSocket and secSsl ?

I am trying to upgrade a current project to use SSL because I have a ServiceMethod which return HTML content with some javascript. In this javascript code, I call the WebAPI "navigator.share" which only works on secure (HTTPS) domains.

So I created a self-signed certificate, registered the route, everything good at this point, I can browse the document on HTTPS and execute the javascript code.

The server answer some interface services, and send push notification through websockets, but to get HTTPS working, I had to change "useBiDirSocket" to  "useHttpApiRegisteringURI" to the server declaration, but after this change, I am out of WebSockets support :

fRestServer := TRestServerDB.Create(fModel, 'vremotesagas.db', true);
fHttpServer := TSQLHTTPServer.Create(PORT_NAME, [fRestServer], SERVER_URL, useHttpApiRegisteringURI, 32, secSsl); // initially set with useBidirSocket and secNone
// fHttpServer.WebSocketsEnable(fRestServer, SAGAS_TRANSMISSION_KEY);//.Settings.ClientAutoUpgrade := true;

If I set "useBiDirSocket" with "secSsl" and try to browse a document on HTTPS, i get an AV on "mormot.rest.http.server" line 1020 :

// call matching TRestServer.Uri()
call.Method := Ctxt.Method;
call.InHead := Ctxt.InHeaders;
call.InBody := Ctxt.InContent;
serv.Uri(call);     <------------------- serv is nil

#164 QuickJS » Sample project somewehere ? » 2021-05-05 14:39:36

flydev
Replies: 2

Hi,

Is there a project sample somewhere ? if not maybe someone have one helloworld project to share on Github smile ?

#165 Re: mORMot 1 » External Zeos MySQL tables with underscore ( _ ) cannot be registered. » 2021-04-12 11:15:50

turkerali wrote:

So the problem should be elsewhere.

Look like in Zeoslib, see comment on line 4640 of the file "ZDbcMetadata.pas" (zeoslib 7.2.10):

{**
  Set the Wildcards character for WildcardsArray variable.
  Overrride this method if the wildcards character is different in other database
}
procedure TZAbstractDatabaseMetadata.FillWildcards;
begin
  SetLength(WildcardsArray,2);
  WildcardsArray[0]:='_';  //<---- seems to be a trublemaker, no idea how to test it with our tests. See http://zeoslib.sourceforge.net/viewtopic.php?f=40&t=13184
  WildcardsArray[1]:='%';
end;

If you read the post following the link, you will find a workarround and a discussion there: https://zeoslib.sourceforge.io/viewtopi … 2&p=160450

#166 Re: mORMot 1 » mORMot2 Wrapper generation broken » 2021-04-12 10:13:54

Okay, tried with your sample and I can confirm then.

#167 Re: mORMot 1 » mORMot2 Wrapper generation broken » 2021-04-10 06:06:26

Just to say that it works on my side on Delphi 10.4.2 pro.

The only things I have to fix afterward, it's the included units (still generate "unit uses" from mORMot v1) :

uses
  SynCommons,
  mORMot;

and to comment the TTextWriter initialization :

// TTextWriter.RegisterCustomJSONSerializerFromText 
[...]

#168 Re: mORMot 1 » New Statics for mORMot » 2021-03-29 06:41:18

Compiled / run successfully on Delphi Sydney 10.4.2 smile Thanks for QuickJS cool

#169 Re: mORMot 1 » new book about mORMot » 2021-03-23 07:14:39

Just a small question to be sure, as the last post here is from 2017, the EWB book 2nd edition is about mORMot too, right ?

#171 Re: mORMot 1 » mORMot 2 in Good Shape » 2021-03-22 07:38:49

Downloading the source and the static files version 3.34.1 from there :  https://github.com/synopse/mORMot2/releases

ask for the 3.34.0 static files when running an executable, is this expected ?


Capture-d-cran-2021-03-22-083337.png

#172 Re: mORMot 1 » Server crash / NewRun event » 2021-03-19 09:18:35

mpv wrote:

Currently for Windows instances we always create a copy of a active log file before opening it in LogView to prevent such unexpected errors

Thanks you @mpv, that's what I ended doing smile

#173 Re: mORMot 1 » Server crash / NewRun event » 2021-03-18 14:10:21

Thanks for the hint @ab, I reproduced it, in fact, I was opening the log file with the LogViewer while the soft was running.

#174 mORMot 1 » Server crash / NewRun event » 2021-03-16 10:01:21

flydev
Replies: 4

Hello all,

Two hours ago I suffered a "crash" and I am trying to find the culprit (me for sure smile) as I am quite new to this framework.

Note: It is possible that timeout are misconfigured and that I misunderstand the flow of the session expiration/client re-connection even if everything can run a week without any error or interruption


The setup is the following:
- Clients and server are built on mORMot2
- a database server (MariaDB 10) on a Windows server
- the (mORMot) server is an instance of TSQLHttpServer and hosted on the same computer as the database server
- the (mORMot) clients (~83 in the wild) are instance of TRestHttpClient and run on Windows 7 embedded

----------------

Server definition and timeout (maybe wrong and I should set it to a greather value) :

constructor TSagasServer.Create(Props: TSQLDBZEOSConnectionProperties);
var
  Conn: TSQLDBConnection;
begin
  fProps := Props;
  fProps.ConnectionTimeOutMinutes := 1;
  [...]
end;

Client definition and timeout (3000 ms)

fClient := TRestHttpClient.Create(AnsiString(SERVER_URL), PORT_NAME, fModel, false, '', '', 3000, 3000, 3000);

----------------

Suddenly, all the clients (~83) disconnected at the same time (by timeout ? from what I see in the client logs) :

client side wrote:

    > 16/03/2021 08:55:00.496    Exception     EWinHttp {Message:"winhttp.dll error 2EE2 (timeout)"} [] at 6af783  stack trace API (TZOracleConnection.PingServer)

And on the server side, 15 seconds before (at 08:54:46) :

server side wrote:

    > 3/16/2021 08:54:45.944    Enter     mormot.rest.sqlite3.TRestServerDB(02b56e10).URI PUT root/Capteurs/10?session_signature=258902d3016d2b0916971c8c in=464 B
    > 3/16/2021 08:54:45.944    User auth        mormot.rest.server.TRestServerRoutingRest(0308cba0) kingspark/629736147 1.2.3.4
    > 3/16/2021 08:54:45.944    SQL     mormot.db.sql.zeos.TSqlDBZEOSStatement(02b76530) ExecutePrepared 1.42ms wr=1 update Capteurs set NumeroConcessionnaire=0,NumeroParking=15,NumeroBorne=1,Etat_Monetique=0,Etat_CB=0,Etat_Imp_Sortie=0,Etat_Imp_Sortie_Papier=0,Etat_Imp_Sortie_Papier_Low=0,Etat_Laser_Entree=1,Etat_Laser_Sortie=0,Etat_Imp_Entree=1,Etat_Imp_Entree_Papier=0,Etat_Imp_Entree_Papier_Low=0,Barriere_Entree_Open=0,Barriere_Sortie_Open=0,Type_SIP=0,Etat_Connexion_SIP=0,WatchDog=0,WatchDog_UserStop=0,Update_time='2021-03-16 08:54:36',Site_Link=0 where ID=10
    > 3/16/2021 08:54:45.944    Server        kingspark 1.2.3.4 PUT root/Capteurs Write=200 out=0 B in 1.56ms
    > 3/16/2021 08:54:45.944    Leave     00.001.574
    > 3/16/2021 08:54:46.240    Enter     mormot.rest.sqlite3.TRestServerDB(02b56e10).URI POST root/UpdateService.Get?session_signature=258902850056589b9976698e in=46 B
    > 3/16/2021 08:54:46.240    User auth        mormot.rest.server.TRestServerRoutingRest(0308cba0) kingspark/629736069 1.2.3.4
    > 3/16/2021 08:54:46.240    Service call        mormot.rest.sqlite3.TRestServerDB(02b56e10) IUpdateService.Get[{numeroParking:15,numeroBorne:3,typeBorne:1}]
    > 3/16/2021 08:54:46.288    New run     ==================================================

server side 5 seconds later wrote:

3/16/2021 08:54:52.208    Exception     EHttpApiServer {LastError:1229,LastApi:"hSendHttpResponse"} [HttpSvr 61337 root THttpApiSvr] at 6c3aa7

About this last error exception, I read on this forum that it could be a timeout misconfiguration..

And the really strange part (to me) is the "New Run" event which poped multiple times each 100ms on the server side - I don't really know at this time what this mean.. please see the following pastebin log file :
   
    > https://pastebin.com/9ZL8ndxj


----------------

To get back running everything, I paniked and restarted the server manualy, the first time I was still getting the execption ERROR_CONNECTION_INVALID.


Any hint please ?   What I can/should add to this post so it will be more clear to you and easier to help ?

Thanks yo guys, have a nice day.

#175 Re: mORMot 1 » mORMot 2 in Good Shape » 2021-01-19 12:59:49

ab wrote:

Note that the ORM with external DB has not be fully validated yet.
Feedback is welcome, because it is hard to validate on all DB/Library/OS combinations out there...

Thanks @ab,

I will test with external db and I will report it.

#176 Re: mORMot 1 » mORMot 2 in Good Shape » 2021-01-19 09:35:31

Awesome, does it mean I can clone the project and recompile my fresh project under mORMot 2 ?

#177 Re: mORMot 1 » MOrmot2, Zeos and Delphi 10.4.1 » 2020-12-14 15:17:16

Ok I understand much better. I know it's not ready for production, I am testing it and preparing myself for the release, as well contributing by reporting bugs.

Thanks Arnaud for the answer and again for the work put in Mormot.

#178 mORMot 1 » MOrmot2, Zeos and Delphi 10.4.1 » 2020-12-14 14:47:37

flydev
Replies: 2

Hello,

I am new here and I adopted a Mormot v1 some weeks ago and I must say that I am astonished by the strength and the simplicity of the framework

I started to port a - still small - project to Mormot v2 and I ran into an AV when running the program (quite simple), it look like it's related to Zeos and not Mormot but as I am a beginner with Mormot I prefer to ask/post first here.


My setup :
- fresh Delphi Sydney 10.4.1 install (tested on earlier version 10.4 and found a post here in this forum about a compiler bug reported which should have been fixed in 10.4.1)
- fresh clone of mormot2
- latest ZeosLib 7.2.8 (also tested old version)


I can compile and run the test without any issue. But once I try to use external MariaDB database with ZeosLib (it works fine with Mormot v1 and Zeos 7.2.8)


So starting with the following code :

begin
var
  Props: TSQLDBZEOSConnectionProperties;
  aPassword: RawUTF8; // aPassword is set on command line 

Props := TSQLDBZEOSConnectionProperties.Create(RawUTF8('zdbc:mysql://localhost:3306/mydatabase?username=mylogin;password=' + aPassword), 'mydatabase', 'mylogin', aPassword);

[...]
end;

It compile fine, but when running the program crash there :

procedure ClassToText(C: TClass; var result: RawUTF8);
var
  P: PShortString;
begin
  if C = nil then
    result := ''
  else
  begin
    P := PPointer(PtrInt(PtrUInt(C)) + vmtClassName)^;
    FastSetString(result, @P^[1], ord(P^[0])); ❌
  end;
end;


The call stack :

Capture-d-cran-2020-12-14-154354.png



Any hint ? 


Thanks Arnaud and all contributors for this framework smile

Board footer

Powered by FluxBB