You are not logged in.
Yes, you can implement a JWT-based authentication endpoint in your server. Could either be provided directly by your server (via a secret key) or integrated with an existing identity provider like Hanko or Auth0.
hi, hard to say without more details. Start by enabling log with LOG_VERBOSE level then check logs once it happen again.
v.a := _Arr(['2']);
//
_safe(v)^.Values[0] := _Arr(['3']);
_safe(v.a)^.Values[0] := '4';
//
DocDictFrom(v).Update('a', _Arr(['5']));
with DocListFrom(v.a) do
U[0] := '6';
{"a":["2"],"b":"2"}
{"a":["3"],"b":"2"}
{"a":["4"],"b":"2"}
{"a":["5"],"b":"2"}
{"a":["6"],"b":"2"}
@youssef, remove route and add the correct one with https scheme. Your issue seem to be the route is already registered for http.
read this:
link to documentation + windows tool:
https://synopse.info/forum/viewtopic.ph … 368#p42368
I think @zen010101 is suggesting you this post:
https://synopse.info/forum/viewtopic.ph … 664#p27664
A README file would be great too, to explain what each sample is about
Sure, thanks.
I like the idea @mpv
@ab is there any rules to follow before making PRs about pushing some samples dedicated for mormot2?
I finished to write a vanilla js lib which support mormot custom auth scheme that will be available on github and i would like to provide samples projects about it.
I have other projects as well, like client/server websockets, an mvc dashboard, etc. I thought they might be useful to other developers.
... because I will speak at two great places:
- the danish Delphi user group - see https://blog.synopse.info/?post/2024/10 … of-Denmark
- the EKON 28 conferences - see https://entwickler-konferenz.de/speaker/arnaud-bouchez/
I’m hoping to be there at the next EKON you’ll be participating in to learn, listen to your insights, and finally ask a question I’ve been wanting to ask for over five years! Enjoy the sessions
@cadnan, see gpt o1 suggestions:
Hi, I’ve just published a project that you might want to check out. Its based of a larger project I’m working on (inspired by Rails ActionCable and designed to work with mormot MVC). I’ve stripped the code a bit, so you’ll get a WebSockets server and some event handling. I’ve also included a JS client for chat functionality.
I’ll try to create a lighter sample this weekend based on the example you linked from Embarcadero.
You will need NPM or yarn installed to run the js project. I can build it to be ran without js tooling, just let me know. Anyway, you can connect with any websockets client on `ws:127.0.0.1:8082/cable` endpoint.
Files of interest:
- chat_channel.pas
- token/token.pas
- http-server/ws_server.pas
Do not pay attention to InitMVCApp and other mvc things.. hope it help
求大神指点一下啊
Sure, but please do some effort to post in english [3]..
meanwhile a better answer, read: https://www.synopse.info/forum/viewtopic.php?pid=42232
and https://www.google.com/search?q=site%3A … m+Error+87
Hi,
are you talking about http.sys? if yes, read there: 11.6.2.2.3. Manual URI authorization
(windows gui tool: https://codeplexarchive.org/project/httpsysmanager)
If not, then a good chinese<>eng translator for posting here can be found at deepl.com
@ab, confirmed: All tests passed successfully.
Sounds like if this CPU is way too slow to generate the RSA keys without a timeout.
This makes sense, thanks you.
I couldn't see any call to `Server.AuthenticationRegister(TRestServerAuthenticationDefault)` or so in this example.
as scheme name let suggest, it's implemented by default when using `true` for HandleUserAuthentication on Create*(), see lines mormot.rest.server.pas#L6176-L6181
EXC EModelException {Message:"TAuthUser is not part of TOrmModel root=root"} [Main] at 443f23
TFileAuthUser is just derived from TAuthUser. Pheraps try with a more basic sample and then go further, I just published a project based on @martindoyle sample (04) and using a part of @tbo example, you should be able to compile it on D7, grab it from flydev-fr/sample_interfacebasedservice
Hope it help.
On my side and also on Windows 11 23H2 22631.4169, test of mormot v2.2.8610 (commit 34b4c7c from 2024-10-02) fail at fetching mustache specs from github (in test.core.data).
! - Mustache renderer: 5 / 62 FAILED 1m36
Running microsoft curl.exe with `curl --verbose https://raw.githubusercontent.com/mustache/spec/master/specs/interpolation.json` fail
* schannel: remote party requests renegotiation
* schannel: renegotiating SSL/TLS connection
* schannel: SSL/TLS connection renegotiated
* schannel: failed to decrypt data, need more data
but with original curl.exe, there is no error (it use embedded CA bundle)..
* Trying 185.199.110.133:443... (githubusercontent.com)
* ALPN: curl offers h2,http/1.1
...
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256 / [blank] / UNDEF
* ALPN: server accepted h2
On a embedded computer running on win7, the mustache test passed.
Note, without hijacking op thread, an os exception was triggered on first run and a second run returned a different result:
- first run log: https://pastebin.com/raw/PFQxFmez
- second run: https://pastebin.com/raw/xDLU21V0
Windows 7 SP1 (6.1.7601) [WinAnsi 1.7GB 1DB10A01] 4 x Intel(R) Celeron(R) CPU J1900 @ 1.99GHz [1MB] (x86) on iEi H788 V1.00
you can find an example there: https://github.com/synopse/mORMot2/blob … #L160-L174
LogCompressAlgo is defined as global var in mormot.core.buffers, so include both units buffers and zip as @ColdZer0 said.
As the error say, routing name 'Product' (TOrmProduct) already exist when you register your Product (IProduct) interface. As the framework use automatic serialization via rtti, an error is triggered when you use same name for interface (service) and table (storage).
In other words, your interface is translated to 'Product' and your table to 'Product'.
To avoid these errors, just be consistent in your naming convention, eg. name your interface `IProductService`. You might register a custom serializer to evade from this, but I didnt used it, so wait for another answer
Just pushed an update for people interested to see an example of the mvc app using automatic translation based on the msg reference files. Every user, guest or logged, can set his own language kept in cookie session.
ps: I am not claiming it's the right way of doing it as it seem ugly to create and free a changed language on render.
It can be compiled on lazarus. Anyway, the feature is really cool for an hybrid desktop app.
Just keep in mind what's already said as you will need these references, then read New Async HTTP/WebSocket Server blog post to get a better overview and then run/study the code of the program used for the techempower benchmark which is IMO the best starting point as it show almost all of what you will need for your endpoints, without complexity.
Just grab the project, uncomment USE_SQLITE3, compile and test urls with Postman, browser or favorite tool.
Hi, I can understand your point of view but some statements are false like about the documentation, at contrario the doc is quite gigantic and can be complex on the first read - but once you get a bit familiar with the framework structure and conventions, the doc turn easy to understand and will became your handbook, and it's still also true if we take into account that the current full documentation is about the version 1.
From the ground up, I can only suggest to read the whole introduction which include chapter 1, 2 and 3 - then play without getting into details with the samples, I mean compile, test and then read the code, then going from code to the documentation to make some corelation, also, the whole source code contain detailled comments.
You can find also Thomas (tbo)'s tutorials (read the readme linked on github), and to be honest, the full samples from the v1 are still useful.
Some links:
- doc v1 (v2 is a wip)
- Thomas tutorials (you will find write up, translatable, on delphipraxis)
- Stephan Bester's intros on Medium
- Again, some tutorials based on the v1, but still applies!
- A lot of samples there
The learning curve is rude, but definitely worth it.
Okay, I'll start experimenting with this workflow.
Regarding images, I wanted to know how others do it, like storing images as a blob or other techniques, but after my post, I think that in my case this would definitely not be the way to go. As for the redirection, perhaps I could use it to trigger an initial request to generate the images before a user even visits the page, and thus save a few ms. I hadn't thought of that.
Thanks for your insight @ab
Hi there,
My first question is what would be the most optimized way to implement a multilingual setup based on mvc-blog example?
My second question is about images, I was just wondering how are you used to handle image(s) in post on your side?
On my side, I have deployed a standalone imgproxy server; An user can then insert in HTML content code a shortcode, for example `{{img="/blurred/image1.jpg" alt="..."}}` (`blurred` is a preset and handled by imgproxy).
Once the article is saved, a new folder is created using article's ID as folder name - eg. `/.static/images/{{ID}}` - and the image is uploaded into this folder - as the image server point to `/.static/images`, he can then handle images variations, cache and serve webp images along some custom presets. Everything works very good and there is not impact, SEO practices at 100%.
Thanks
@Lauri I didn't tested on Delphi 2007, but the bugs are still there in Delphi 10, 11 and 12, and only if an invalid variant value exist.
If the variant is valid, you can inspect it and move your mouse hover it, but if you are stepping through code and move cursor hover an invalid variant, the IDE hang and you have to kill it; Killing LSP process only do not work.
The only way I found to avoid the crash, is to move the cursor out of the IDE and starting debugging using keyboard's shortcuts, inspector will show variant (valid/invalid) values. Also, when an AV is triggered, use the keyboard, not the mouse.
That doesn't happen in Lazarus. Years of frustration yes, but if there was only this issue, we could live with it **clown emoji here**
Take this simple example to get started.
type
TOrmMyObject = class(TOrm)
FTitle: : RawUtf8;
FStatus: int32;
published
property Title: RawUtf8 read FTitle write FTitle;
property Status: int32 read FStatus write FStatus;
end;
// ...
procedure GetIList;
var
list: IList<TOrmMyObject>;
obj: TOrmMyObject;
begin
if FHttpClient.Client.Orm.RetrieveIList(TOrmMyObject, list, 'ID,status,title') then
begin
ConsoleWrite('retrieved % objects', [list.count]);
for obj in list do
ConsoleWrite('Obj ID %: title=%, status=%', [obj.ID, obj.title, obj.status]);
end;
end;
A note about finding features in mormot, when I started with mormot I was used to go in the v1 documentation and using text search to find keywords; You can apply the same flow with the source-code which is nice commented, eg. in the mormot/src folder, just use a tool to search keyword in *.pas files. You will find also a lot of implementation infos by reading the test code from the mormot2/test folder. You can also keep the v1 source code at hand to get more samples adapting them to pure mormot2.
v1 doc: https://synopse.info/files/html/Synopse … l#TITLE_81
source: https://github.com/synopse/mORMot2/blob … ctions.pas
Hope it help.
Thanks for your input. I will post the result for the science.
Good to hear that.
It was an instance of a bidir TWebSocketAsyncServerRest. I will recompile the project next week and upload all the test clients while keeping the server running in the debugger.
@ColdZer0, is everything still ok?
This is what happens after 14 hours, plus the console is not updating anymore.
I am asking because i ran into the same issue in the end of july while testing the new async server, and I want to give another try. I had no junk network traffic as the network is filtered only on known static ips but almost all clients are connecting through 4G routers with sometime high latency and/or random disconnections. The console was "stuck" after ~6h with around 170 clients sending 1 or more requests per secs.
Thanks you both for the debugging and fixes
FPC => OK
On Delphi 11, after adding ISDELPHI11 directive on top, cleaning dcu, it's OK.
Hi,
it seem that OnWebSocketsClosed is not triggered on client side when compiled with last mORMo2 version.
I have the issue on Delphi 11, still not tested on FPC. I tested it with `rest-websockets` project from the example folder, compiling the server and client on a fresh clone.
You can find the client code with `OnWebSocketsClosed` implemented there:
https://gist.github.com/flydev-fr/93902 … a488e1edae
When compiling only the client with mORMot2 (commit fa3cd43097e1e9a89edee94ad0282b17817668a6 from May 12) I can get it working.
Hi @ab,
Replying here about the issue #183 reported on Github - your commit (38f27f08) fixed the / or - exception.
(Sorry for the time lost about the PR, I feel learning more by doing mistake and trying to fix things, to be honest, I had a doubt it was the right correction as you confirmed it on the PR comment that is making sense, lesson learned )
Hi @ab,
I was looking for infos on the forum from my mobile, I must admit it was not easy
You might consider testing an update of the air theme and just adding this single line on the main html file/tpl
<meta name="viewport" content="width=device-width, initial-scale=1.0">
css: https://github.com/natrius/air3/blob/master/Air3.css
Preview Result:
home:
list of threads:
thread content:
And if you want/need some assist to make and validating it on a staging server, I am ok to do it
i edited my last post @missionhq, I confirm the bug at least on 11.2.
Could you confirm you're using the older ver of mormot (before ab's fix)
Yes, the version was from the commits of Nov 22, 2022. Even with Debug/O+, no exception.
@missionhq: did a reset, cloned from commit 74cfbc4 then with debug O+ the exception is triggered on delphi 11.2, I will try when I am back on 11.0 and 11.1.
EAccessViolation: Access violation at address 00941F00 in module 'Project01.exe'. Read of address 076F5980
I tested your sample and I could not reproduce that in 11.0, 11.1 and 11.2, debug or release mode, in 32bit or 64bit. No exception, and element popped.
=> mormot v1 & v2..
Hi, you can take a look there for example (v1, it's easy to port on v2), and in the source of `mormot.crypt.core` for more details (read the comments).
You can also find more recents details on a good blog post .
I just tested the application, your examples really make things easier and give a lot of good implementation ideas, thanks you @tbo
Thanks @ab
Hi,
I had a chunk of code that was calling `Client.TimerEnable` found on this thread made by @tbo (https://synopse.info/forum/viewtopic.ph … 681#p33681)
But after upgrading some weeks ago mORMot, i get the following error:
[dcc32 Error] frmMain.pas(255): E2009 Incompatible types: 'Parameter lists differ'
I see the that the signature defined in `mormot.rest.core` is the following now:
function TRest.TimerEnable(const aOnProcess: TOnSynBackgroundTimerProcess; aOnProcessSecs: cardinal): TRestBackgroundTimer;
And my code was:
frmMain.Connect(pmSender: TSynBackgroundTimer; pmEvent: TWaitResult; const pmcMsg: RawUTF8);
I can't manage to get my brain getting the right call even after reading all the code comments
can someone you give me a hint please ?
I didn't think about that at all. Thanks you ! Will share the result / solution
BTW PostgreSQL on Windows works extremely bad - it designed for Linux
Thanks for insight, indeed, I am migrating the infrastructure on Unix server as Windows Server only bring me problems, especially with database servers.
@daniel thanks, indeed the executable is compiled in 64bit. I double checked with a PE tool after compilation.
I must add FYI, that I tried to load the lib with this simple call
var Handle := LoadLibrary('libpq.dll');
if Handle <> 0 then
WriteLn('OK')
else
WriteLn('BAD');
and it return 'BAD'
with the env PATH modified, it return 'OK'.
I also read the whole following thread found on Lazarus forum: https://forum.lazarus.freepascal.org/in … 4cpaer7mh3
I will come back for sure to this issue as the solution to modify the ENV path like in my first message is only viable for my local dev environment.
Hi,
I'am scratching my head with this.
ESqlDBPostgres {Message:"TSqlDBPostgresLib.TryLoadLibray failed - searched in C:\\Users\\flydev\\Documents\\Embarcadero\\Studio\\Projets\\SagasEnv\\RemoteBlock2\\bin2\\libpq.dll, libpq.dll",Statement:null}
I installed Postgres 14, copied the libs (crypto, iconv, libintl, libssl, zlib and libpq.dll) in the same directory of the executable, I tried to add as well this dir on env PATH, but nothing.
Is there something special to do ?
---
Edit: Just added `C:\Program Files\PostgreSQL\14\bin` to the env PATH and it's working..
Nice serie ! Keep up the good work Thomas
Hi @ab, just sponsored Synopse, and I left a sponsorship suggestion to the company in the preamble of the documentation, and by direct mail as well.
Doing war with guns and missiles in 2022.. Please stay safe mpv ... I also have a thought for the russian people who don't agree... I was going to ask help about a programming thing but after reading this thread I'm going to get some sleep... what a madness
True, and so, with the documentation chapter #13.2, the #6.2.4 sentence and the following blogpost, the road should be shorter:
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
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.
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.
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
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 ?
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 :
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