You are not logged in.
Pages: 1
And this is an example I created a while ago when I was researching mORMot2.
Ab,
I always try to understand what I am doing. Believe me, I avoid asking in this forum because of the intimidating way you respond to some people here, without knowing precisely what each user may have done before asking, but for this case, it simply didn't work. I also tried to google some responses using mormot stuff, but I also found nothing. I didn't invent the private key. There is one page with some steps to find a final result, starting with a 256-bit private key given by them (the one used in my post, as well as the result public key from the original private key, also posted there). It is a 256-bit private key as it is supposed to be, the SAME SIZE of the one used in your 'test.core.ecc', line 89. In fact, I just realized that the key you used in that example also doesn't pass the test above ('DC5B79BD481E536DD8075D06C18D42B25B557B4671017BA2A26102B69FD9B70A'). So, I am using the same functions used in your tests and it is not working. I just need to calculate a 256-bit public key for a well-generated 256-bit private key, as is the case in my original question, and I am trying to use the mormot one because looks like they are fast.
I would recommend making sure that the one you are using is ecc256r1 and not ec25519, Because mORMot2 only support the ecc256r1.
That's great; I will create a server, create the channels and other needed stuff, and send you the link to publish.
Hello All,
mORMot2 is an excellent framework that deserves to be known more in the development comminutes.
In the last few years, Many people have been using Discord to create communities related to the development of their projects.
@ab Have you ever considered creating a Discord Server for mORMot development?
It's viral and attracts a lot of attention. It's easy to interact with people fast.
Plus, the voice chat element is perfect; people can share their work or do live streaming, helping each other.
And I would love to hear what people around here think about this.
Regareds.
You don't have to edit the mormot2 source code.
All you need to do is add "mormot.core.buffers, mormot.core.zip" in your uses.
And at the start of your app or the log init part
"LogCompressAlgo := AlgoGZFast;"
In my projects, I'm using OnBeforeBody. It's a good point to check for API tokens or header values.
For example, I've had this in one of my projects.
function TMainServer.BeforeBody(var aUrl, aMethod, aInHeaders, aInContentType, aRemoteIP, aBearerToken: RawUtf8; aContentLength: Int64; aFlags: THttpServerRequestFlags): cardinal;
var
AuthData : String;
Begin
// Always return HTTP_UNAUTHORIZED if there's any problem ^_^
Result := HTTP_UNAUTHORIZED;
// If user asks for time/ping we allow it
if (LowerCase(aUrl) = '/api/v1/time') or (LowerCase(aUrl) = '/api/v1/ping') Then
begin
Exit(HTTP_SUCCESS);
end;
if aBearerToken <> '' then
begin
AuthData := Base64ToBin(aBearerToken);
// Check Telegram webapp initData
if IsValidTelegramUser(AuthData) then
begin
if IsAllowedUser(GetUserIDFromToken(AuthData)) then
Result := HTTP_SUCCESS;
end;
end;
End;
The main QuickJS repo has been very active lately.
Hello,
I recently started using IDocDict and IDocList, and everything works well.
But there's a small thing I can't figure out.
Is there a way to read a value from a JSON path, for example, this data
{"@type":"updateNewMessage","message":{"@type":"message","id":123456789,"sender_id":{"@type":"messageSenderUser","user_id":123456789},"chat_id":123456789,"is_outgoing":false,"is_pinned":false,"can_be_edited":false,"can_be_forwarded":true,"can_be_replied_in_another_chat":true,"can_be_saved":true,"can_be_deleted_only_for_self":true,"can_be_deleted_for_all_users":true,"can_get_added_reactions":false,"can_get_statistics":false,"can_get_message_thread":false,"can_get_read_date":false,"can_get_viewers":false,"can_get_media_timestamp_links":false,"can_report_reactions":false,"has_timestamped_media":true,"is_channel_post":false,"is_topic_message":false,"contains_unread_mention":false,"date":1711194238,"edit_date":0,"unread_reactions":[],"message_thread_id":0,"self_destruct_in":0.000000,"auto_delete_in":0.000000,"via_bot_user_id":0,"author_signature":"","media_album_id":"0","restriction_reason":"","content":{"@type":"messageText","text":{"@type":"formattedText","text":"/start","entities":[{"@type":"textEntity","offset":0,"length":6,"type":{"@type":"textEntityTypeBotCommand"}}]}}}}
Can I do a reading using the full path
function ReadMsg(JSONStr : String) : String;
var
JSON: IDocDict;
begin
result := '';
if IsValidJson(JSONStr) then
begin
JSON := DocDict(JSONStr);
result := JSON.S['message.content.text.text']; // Can I do that using mormot?
end;
end;
And for the Exists method
if JSON.Exists('message.content.text') then
Thanks.
Hello @ab
Any updates on this https://github.com/synopse/mORMot2/pull/231, Especially the _write bug.
I found a bug in the static unit and sent a fix in the same pull request.
I end up using NOLIBCSTATIC
I created a pull request because it needed some extra fixes so the code could compile
Hello
I was working on my project ImGui-Pascal, and It requires linking with some Windows libraries, one of them is msvcrt
And I was recreating one of my projects to use it as a UI and mORMot2 as the backend.
The problem is these APIs are already defined in src\lib\mormot.lib.static.pas
Error: Multiple defined symbol "__strtod"
Error: Multiple defined symbol "__imp__localtime64"
__strtod is only used by src\lib\mormot.lib.quickjs.pas, which can be handled with an IFDEF if QuickJS is used.
But the real problem is imp_localtime64 := @localtime64; which I assume is used for some other library (not sure).
So, what do you think about this case?
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.
Then yes your sever was definitely affected by the bug, and recompiling it with the latest update will solve it.
@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
For me, everything still works very fine ( the server has been running for 5 days 16 hours - from the last update I did to the server code not from the last WebSocket fix )
So everything works very well.
What kind of Async server you are using? WebSocket ? or just HTTPAsync Server?
Because the problem with the WebSocket one has nothing to do with the HTTPAsync Server.
Everything seems to be stable after yesterday's fixes.
Thanks for your work and the great framework.
I have a question regarding exceptions at functions like
function TWebProcessInFrame.GetHeader: boolean;
Do we need exceptions here?
Like
EWebSockets.CreateUtf8('%.GetFrame: truncated mask', [process]);
Can't we return false on errors because exceptions like these hang the Debugger while testing?
The GPF with the hsoBan40xIP fix has worked fine till now.
I've been testing it for 30 mins since you pushed the commit. I'll keep testing.
And for the lock, I just pulled the changes and will test it and see if everything works fine.
Thanks for your hard work and updates.
So after running for a while, the high CPU thing happens, and here's some call Stackframe for a couple of threads, and all of the high CPU ones stuck either at
Procedure TRWLock.WriteLock;
or
procedure TRWLock.ReadOnlyLockSpin;
and all of them come from
TAsyncConnections.ConnectionFind
TAsyncConnections.ConnectionFindAndLock
Here's screenshots
and
I'll try to check with fewer threads to see if I can catch what is happening.
After doing some testing with the debugger.
Here's the first error "Access Violation" at the "IsBanned" function.
It only happens when I enable "hsoBan40xIP"
The last test I'm doing right now has the hsoBan40xIP and hsoLogVerbose options in the server
And I'm doing a LOG_VERBOSE for the TSynLog.Family.Level
Right now the server has been running for 13+ hours and the server status seems stable
If the server reacts the same as before I'll send you the full server logs in a private message.
So I noticed yesterday that I was not enabling the Windows firewall
Then After enabling it and I already have a list of IPs to block they were doing DDOS attacks on the server
the server still running and I blocked more IPs
Here's an example The number of WebSocket connections that I counted was way less than the console shows
Then I checked the list of connected IPs and found 1 IP connected to the server 200+ times, I blocked the IP and a couple of other malicious IPs
The number decreased after killing the multiple connections
And I noticed in the screenshots I sent before that there was a spike in network data up to 2GB in traffic which is odd.
I'll keep the server running with the firewall and list of blocked IPs and see if it affects the result of the test.
Then I'll do another test with verbose enabled.
Now I have a question regards the TCP connections in the "TWebSocketAsyncServer"
Can I intercept the connection at the beginning even before the WebSocket upgrade?
I want to make some internal checks to test for any multi-connected IPs or other malicious IPs.
Could you try to compile the server with FPC and see what happens on Linux?
I can't with this server because it is built for Windows with a GUI controller for status and some other options.
But I was already working on a new rewrite for the project to be compatible for Linux and with REST server without the GUI stuff and only APIs.
Right Now I added the ConsoleWrite you mentioned
The server has been running for "12 hours +" and waiting to see what will happen
BTW I'm using "TWebSocketAsyncServer" and all the connections sending data all the time like ping and other small text chat data
For now, this is the network status.
And for the performance for now it uses only 88MB of RAM and less than 1% of CPU which is amazing.
I'll try to enable full logging after this test and share it with you.
This is what happens after 14 hours, plus the console is not updating anymore.
Hello @ab
I still got a high CPU on the Async web socket server with 1500+ concurrent connections for 26+ hours
I was checking the server status and I found out that the server CPU was 90+%
When I checked the threads it was all from mORMot Async server threads
Each thread was using around 5..6% and on the stack, every single one of them was doing SwitchToThread
I'll try to use something like ProDelphi64 or if you have any recommendations on how to trace this down I'll be happy to hear from you.
or try to run it under the IDE debugger for as long as I can.
I'm using mORMot2 v2.1.5824, Delphi 11.3 and the server is running on a Windows
I got the same error on logs after keeping the server running for a couple of hours.
I'll try to enable trace logging and see if I can get it to have the same issue again.
Hello guys,
I was looking at the source code of Mormot2 to see if there's any way I can upload a file to TWebSocketAsyncServer, which is based on THttpAsyncServer.
But with no luck.
So is there any way I can upload files to the Mormot2 HTTP server, and if mormot 2 HTTP servers support multipart file upload?
I'm looking to upload files of 1GB to 5GB in size.
Regards.
Hello ab,
Please check my last comment https://github.com/synopse/mORMot2/issu … -954962300
I add a git patch propose some changes to let the TAsyncClient work as expected.
Hello ab,
I Notice today that there's an update on the TAsyncServer But not the TAsyncClient
https://github.com/synopse/mORMot2/comm … 2538a2f0c4
Is there any update coming for the TAsyncClient OnRead Problem ?
Thanks.
Thanks for reply.
Yes I'll use Linux But I was testing windows for other project I've in mind.
And About the TAsyncClient there's no release for the "atpReadPoll" that's why I called ThreadPollingWakeup.
I think TAsyncClient needs to be updated.
One thing I notice is when I use TAsyncConnections with 1 thread count the reading is working fine once the ThreadPoolCount is bigger than 1 there's no OnRead call.
Hello ab
So basically I took a good look at the TAsyncServer and the TAsyncClient and the main difference is the Server has a mechanism to notify the ReadPoll to handle new subscriptions, But the Client didn't have.
So What I did is adding the following code in the "ConnectionCreate" CallBack.
// assign the new connection to the internal reading poll.
If Clients.Start(aconnection) Then
Begin
// release atpReadPoll lock to handle new subscription ASAP
ThreadPollingWakeup(fClients.PollRead.PollForPendingEvents(0));
// Send 2MB As Test - we should receive it
WriteString(aConnection, DupeString('A', 1024*1024*2));
Result := True;
End
Here's the new Client Code
https://gist.github.com/Coldzer0/226e0d … 4485594e28
It Works well for Reading and Writing (Still didn't test it fully).
I didn't add my code in a PR because I didn't know how it suppose to be handled in the test ( I'm new to mORMot internals ).
Please Check it and let me know if it's Ok to use it like this or if there's a better way.
Thanks.
Thanks ab for reply.
First of all thanks so much for the amazing work in mORMot2.
Do you have any number to share?
Sure
The Sever RDP
The Machine I uses for Server is "CPU= 5 x Intel(R)Xeon(R)CPUE5-24200@1.90GHz(x64) - RAM= 8GB"
This is a x64 Debug Build with Delphi Memory Manager.
Built with Delphi 11 Alexandria : Debug Mode
Memory Usage: About "50MB" for "11,166" concurrent Connections With 16 Async Threads (TAsyncServer).
CPU Usage : Between 17% & 18% never higher.
Even when it reach the 13,000+ It was still very small memory usage about "52-54 MB"
Here's a screenshot from when I was testing.
The Client Side: (I didn't use mORMot2 I used a tool called EchoServerTest to do the testing)
The Stress testing Machine is "CPU=16 x Intel(R)Core(TM)i9-9900KCPU@3.60GHz(x64) RAM= 32GB"
I was aiming for 40000 concurrent connections But windows has limits, I think there's some registry options I can edit to extend the numbers of connections.
Anyway I'll do the test again but with Linux x64 (Will test Release Build Later with mORMot2 Memory Manager).
Could you make a pull request and include your code to the regression tests
Yes no problem I will try my best.
so you can't be notified that the server actually received the data. But it is also the case for plain TCP IIRC.
In normal blocking mode you got the sent length so you can make sure how much of your buffer sent to the server.
But I'll implement custom acknowledgment send by the server to be confirmed by the client as you advised.
I've a question about the internal buffer of the sockets, How can I read a specific size of data keeping in mind that the read and write in Async.
What I mean is how can I make sure that what I receive is the full packet if the size if like 1MB or Bigger keeping in mind that the maximum buffer described in code is "8KB".
Hello guys
I was trying to create an Async raw TCP client & server.
I Created A Server and it works very well It can handle thousands of concurrent connections.
I tested it with a tool for stress testing and I got (about 13,000+ (limited by the client machine) connections On Virtual RDP Server : CPU=5xIntel(R)Xeon(R)CPUE5-24200@1.90GHz(x64) 5 Cores - RAM=8GB ).
Echo Server Code:
https://gist.github.com/Coldzer0/d00c04 … 72765506c5
But when I tried to Create Client with the Code of use of mORMot2 TAsyncClient Everything works except for the OnRead, when I try to send any data to the client the OnRead never called.
Client Code:
https://gist.github.com/Coldzer0/8c98a0 … 89791f55e4
And I've another question about Async send, How can I make sure that the server received the sent data or not ?
And please let me know If I'm doing anything wrong, And If there's any good demo of showing how to deal with RAW TCP Client & Server with mORMot2.
Hello all,
This is a FPC & Delphi bindings for QuickJS @ https://bellard.org/quickjs
I hope this will help someone ^_^
This is known problem. Most of the size take libicu with all known languages inside. So, without-intl-api and without-system-icu will strip this library and decrease size, but you lost Internationalization API. For example we use it widely. The possible way to keep Intl and decrease size is to remove unneeded resources from libicu
Also disable-ion is IMHO not decrease library size but you lost JIT - very, very big performance degradation
i'll try to enable ion again
in my project i don't need "icu" so i think it's ok to remove
and is there any place i can find more info about
--disable-ion -> i know now it's for JIT
but what about
--disable-jm
--disable-tm
--disable-methodjit
--disable-monoic
--disable-polyic
etc ...
i can't find any resource that give details about these options
this's the smallest size i get so far 6.8MB
with this config
../configure --enable-release --disable-ion --enable-ctypes --disable-jemalloc --enable-nspr-build --disable-debug --disable-debug-symbols --enable-optimize=-O3 --without-intl-api --enable-strip --disable-ion --without-system-icu
Hello all
i'm really glad that i found this project
i'm working on a Project Called "Cmulator"
Cmulator is ( x86 - x64 ) Windows PE Sandbox Emulator & Disassembler
Based on Unicorn & Capstone & Besen Engine .
the main core functions built with FreePascal and API hooks with JS Engine "Besen"
but Besen Engine is old and slow , that why i’m interested in your product , as there’s no small and native Pascal JS Engine out there .
a small preview of what JS will be used for in my project
this’s a small Example to Hook "GetModuleFileNameA & GetModuleFileNameW" with JS
var GetModuleFileName = new ApiHook();
/*
DWORD WINAPI GetModuleFileName(
_In_opt_ HMODULE hModule,
_Out_ LPTSTR lpFilename,
_In_ DWORD nSize
);
*/
GetModuleFileName.OnCallBack = function (Emu, API, ret) {
Emu.pop(); // ret
var hModule = Emu.isx64 ? Emu.ReadReg(REG_RCX) : Emu.pop();
var lpFilename = Emu.isx64 ? Emu.ReadReg(REG_RDX) : Emu.pop();
var nSize = Emu.isx64 ? Emu.ReadReg(REG_R8D) : Emu.pop();
var mName = Emu.GetModuleName(hModule);
var Path = 'C:\\folder\\' + mName;
var len = API.isWapi ? Emu.WriteStringW(lpFilename,Path) : Emu.WriteStringA(lpFilename,Path);
print("GetModuleFileName{0}(0x{1}, 0x{2}, 0x{3}) = '{4}'".format(
API.IsWapi ? 'W' : 'A',
hModule.toString(16),
lpFilename.toString(16),
nSize.toString(16),
Path
));
// MS Docs : the return value is the length of the string
Emu.SetReg(Emu.isx64 ? REG_RAX : REG_EAX, len);
Emu.SetReg(Emu.isx64 ? REG_RIP : REG_EIP, ret);
return true; // true if you handle it false if you want Emu to handle it and set PC .
};
GetModuleFileName.install('kernel32.dll', 'GetModuleFileNameA');
GetModuleFileName.install('kernel32.dll', 'GetModuleFileNameW');
Emu is JS Object have all needed Native functions like "ReadReg" to read Register from the CPU Emulator , "WriteStringA" & "GetModuleName" and a lot more
the main thing here is that i can call JS function from my Native code and vice versa .
the tool Depends on JS as Scripting lang for Hooks and dealing with the CPU Emulator for easy of use and speed .
3 days ago i downloaded and use your project on Mac OS Mojave and it works fine with the linux Patch for exports
but SM is very big 22MB for "libmozjs-52.dylib"
so i'm searching for a way to Build it without the need of Debugger and anything that i can get rid of , even if i'll remove JIT
but i need it small as i can get .
Thanks
Pages: 1