You are not logged in.
Can these two VMs PING each other?
In the mORMot 1 sample "Project31Chat" server-side, how can the interrupt event of the chat client program be captured, for example, when Ctrl-C is pressed?
I found that "ProcessStart/Stop" will be called, but TChatService.CallbackReleased not.
We finish a implementation of WebSockets using HTTP API 2.0 and commit it to branch "WinWebSocket" (BTW merge operation on fossil is very good).
The sample `31 - WebSockets\Project31WinHTTPEchoServer.dpr` give a basic usage.We test out implementation using synthetic tests and successfully create a 50 000 concurrent webSocket connections. One server-side connection required 5kb of memory (and do not create a separate thread)
Also we deploy a solution based on the THttpApiWebSocketServer to one of our production. The average load is 3000 concurrent WS connection with up to 5000 sometimes. It work 1 week w/o problems (but we use WS only to notify a client about something happens, all other communication is done using HTTP).
https://blog.synopse.info/?post/2014/08 … they-scale : Here, AB mentioned:
As a conclusion, I would recommend the following, for any project:
- Use WebSocket for client notifications only (with a fallback mechanism to long-polling - there are plenty of libraries around);
- Use RESTful / JSON for all other data, using a CDN or proxies for cache, to make it scale.
At the same time, in this post, mpv also mentioned:
but we use WS only to notify a client about something happens, all other communication is done using HTTP
I am quite curious about the above perspective, how is it implemented? Could you provide some example code?
Enjoy your time, recharge those batteries, and we'll see you soon with stories to share!
We have several entries in mormot.net.client.pas to initiate an HTTP GET Request, but their default RedirectMax is a bit confusing:
1. IHttpClient/TSimpleHttpClient: 4 times, can be changed before calling Request
2. TWinINet.Get(): automatic, unknown max times value
3. TWinHttp.Get(): 0 times
4. OpenHttpGet() function: 5 times
5. HttpGet() function: 0 times if use winhttp or 5 times as same as OpenHttpGet
6. THttpClientSocketWGet.WGet/WGet() function: 0 times default, can be changed when called
It might be more friendly if we could unify the default values of RedirectMax for different objects or functions written in different periods. ![]()
All works but TWinHttp.Get('https://z.cn', '', True{IgnoreTlsCertificateError}, nil, nil, 3000)) not, it seems not reading the RedirectMax property value.
Neither HttpGet('https://z.cn', ''); .
You summed it up so right. So, mORMot is awesome!
Real metal machine result: Ubuntu, Intel Core i5-1155G7 with 16G RAM
Which compiler did you use?
Win64 as target, I hope?
Yes, Win64 as target, using FPC trunk compiler.
Here is the result running in the same host but in Windows WSL ( Ubuntu ):
https://gist.githubusercontent.com/syno … tfile1.txt
I compiled the mormot version and the go version, and the following are the latest test results. I'm surprised that the Go language version has improved so quickly.
https://gist.githubusercontent.com/syno … tfile1.txt
CPU: Intel(R) Core(TM) Ultra 9 185H
RAM: 32G
OS: Windows 11 23H2
What about QuickLib? https://github.com/exilon/QuickLib
Areas of functionality:
Mapping: Map fields from a class to other class, copy objects, etc..
Config: Use your config as an object and load/save from/to file (Json/Yaml) or Windows Registry.
Serialization: Serialize objects to/from json/Yaml.
Scheduling: Schedule tasks launching as independent threads with retry policies.
Threading: Simplify run and control of multithread background tasks, Thread-safe Lists, queues, etc
Data: Flexible data interchange and storage, allowing several input-output types.
Cloud: Simplify cloud Azure/Amazon file management, send emails and more.
Querying: Indexed Lists, Searchable Lists and Linq query system for generic lists and arrays.
Benchmark: Time elapsed control and benchmark functions.
Filesystem: Process and Services control, file modify monitors and helpers, etc...
FailControl: Fail and Retry policies.
Caching:: Cache string or objects to retrieve fast later.
Templating: Simple string templating with dictionaries.
Debuging: Utils to debug your code.
Parameters: Work with commandline parameters.
So, BIG is not the problem forever .
Confirmed fixed. :-)
New bug:
When creating a thread pool and passing a larger thread value in IOCP mode, TSynThreadPool.Free will enter an infinite loop and block the process.
Here is the demo: https://gist.github.com/zen010101/def68 … 0b028d70d2
Confirm fixed. ![]()
New bug:
When TSynThreadPool is destroyed in the middle of executing the tasks, the TaskAbort is not called, but in Linux, all works well.
see this, compile it for windows and linux to see the differences: https://gist.github.com/zen010101/def68 … 0b028d70d2
The possible issue might be here:
destructor TSynThreadPool.Destroy;
var
i: PtrInt;
endtix: Int64;
begin
fTerminated := true; // fWorkThread[].Execute will check this flag
try
{$ifdef USE_WINIOCP}
// notify the threads we are shutting down
for i := 0 to fWorkThreadCount - 1 do
IocpPostQueuedStatus(fRequestQueue, 0, nil, {ctxt=}nil);
// TaskAbort() is done in Execute when fTerminated = true
{$else} Confirm that the PendingContextCount property can also be used in IOCP mode as the condition for determining the completion of all Task executions.
When WINIOCP is not used, I can determine whether all Tasks have been executed by judging whether PendingContextCount is 0.
I know that I can inherit TSynThreadPool and add a TaskCount property in the subclass, increase the Property by 1 after Push, decrement it by 1 when the Task completes, and use TLightLock to make it thread safe.
But I want to know if there is an easier way? I tried the RunningThreads attribute, but it didn’t work. It is always consistent with the parameters of Create(NumberOfThreads) and cannot be used to confirm the number of Tasks being executed.
Here is my code: https://gist.github.com/zen010101/def68 … 0b028d70d2
In the WinHttp API, redirections are not done automatically.
We may add them.
Very much looking forward to this feature coming online .
This time no exceptions were raised, instead of an error message: "Failed to retrieve the webpage. Status: 301".
I wonder why it doesn't automatically redirect to the new address? After all, in the TSimpleHttpClient.Create method, I read:
fConnectOptions.RedirectMax := 4; //seems fair enough I tried the latest trunk, the winhttp.dll exception remains.
Here is the call stack:
#0 FPC_RAISEEXCEPTION at :0
#1 RaiseLastModuleError($0000000100130B58^: 'winhttp.dll', ExceptClass($000000010012F898)) at mormot.core.os.windows.inc:634
#2 EWinHttp.RaiseFromLastError(^$__vtbl_ptr_type($000000010012F898)) at mormot.net.client.pas:3827
#3 TWinHttp.InternalQueryDataAvailable(TWinHttp($0000000001587310)) at mormot.net.client.pas:3803
#4 TWinHttpApi.InternalRetrieveAnswer(TWinHttpApi($0000000001587310), 'HTTP/1.1 301 Moved Permanently'#$0D#$0A'Connection: keep-alive'#$0D#$0A'Date: Thu, 10 Oct 2024 16:19:24 GMT'#$0D#$0A'Transfer-Encoding: chunked'#$0D#$0A'Content-Type: text/html; charset=iso-8859-1'#$0D#$0A'Location: http://www.amazon.cn/ref=z_cn?tag=zcn0e-23'#$0D#$0A'Server: Server'#$0D#$0A'Strict-Transport-Security: max-age=47474747; includeSubDomains; preload'#$0D#$0A#$0D#$0A, '', '', '') at mormot.net.client.pas:3533
#5 THttpRequest.Request(THttpRequest($0000000001587310), '', 'GET', 10000, '', '', '', 'HTTP/1.1 301 Moved Permanently'#$0D#$0A'Connection: keep-alive'#$0D#$0A'Date: Thu, 10 Oct 2024 16:19:24 GMT'#$0D#$0A'Transfer-Encoding: chunked'#$0D#$0A'Content-Type: text/html; charset=iso-8859-1'#$0D#$0A'Location: http://www.amazon.cn/ref=z_cn?tag=zcn0e-23'#$0D#$0A'Server: Server'#$0D#$0A'Strict-Transport-Security: max-age=47474747; includeSubDomains; preload'#$0D#$0A#$0D#$0A, '') at mormot.net.client.pas:3366
#6 TSimpleHttpClient.Request(TSimpleHttpClient($0000000001581DF0), TUri (True; nlTcp; 'https'; 'z.cn'; '443'; ''; ''; ''), 'GET', '', '', '', 10000) at mormot.net.client.pas:4530
#7 THttpClientAbstract.Request(THttpClientAbstract($0000000001581DF0), 'https://z.cn', 'GET', '', '', '', 10000) at mormot.net.client.pas:4425
#8 $main at test.lpr:56
#9 SYSTEM_$$_MAIN_WRAPPER$POINTER$POINTER$$INT64+6 at :0
#10 at :0
I noticed that the code below is not being executed at all:
if SChannelEnableTls13 and // should be explicitly enabled
((OSVersion in [wEleven, wEleven_64]) or
(OSVersion >= wServer2022_64)) thenUpdate:
Tested on the latest Windows 11 update, the issue remains.
Version Windows 11 Home Chinese Version
Version number 23H2
Installation Date 2024/9/8
Operating System Version 22631.4317
Which version of Windows are you using?
There seem to be some problems with TLS 1.3 support on some Windows 11, with our SChannel TLS layer.
Windows 11 23H2 22631.4169 and Windows Server 2016. Both not work.
i got similar error before, after i modified code in file mormot.net.client.pas as follow, now it works:
...
modified to:
function TWinHttp.InternalGetProtocols: cardinal; ... result := WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 or WINHTTP_FLAG_SECURE_PROTOCOL_SSL2 or WINHTTP_FLAG_SECURE_PROTOCOL_SSL3; ...
1. I found this in the code:
// WINHTTP_FLAG_SECURE_PROTOCOL_SSL2 and WINHTTP_FLAG_SECURE_PROTOCOL_SSL3
// are unsafe, disabled at Windows level, therefore never supplied2. Even if I add SSL2 and SSL3, my program still prompts the same error.
In linux, `/etc/ssl/certs` stores trusted certificates, including CA's. But in Windows, I don't know how to make openssl work to verify the tls cert. Therefore, it is recommended to use SChannel as the TLS layer in Windows, and OpenSSL is preferred in Linux.
Regardless of whether OpenSSL is used as the TLS layer, accessing https://z.cn using TWinHttp on Windows will cause winhttp.dll to report an error.
winhttp.dll error 2EF1 (The operation has been canceled)Whose fault is this?
HttpClient := TSimpleHttpClient.Create;
HttpClient.Tls^.IgnoreCertificateErrors := True;
if HttpClient.Request('https://z.cn', 'GET') = 200 then
ConsoleWrite('Length(HttpClient.Body): %', [Length(HttpClient.Body)], ccGreen)
else
ConsoleWrite('LastError: %', [HttpClient.LastError], ccRed);I have some inquiries regarding this previous thread:
Does a TSynBackgroundTimer utilize a thread to sequentially execute aOnProcess: TOnSynBackgroundTimerProcess?
How can I employ separate threads to execute multiple tasks concurrently in the background? Is it possible to use multiple TSynBackgroundTimer instances for this purpose?
Would you please provide me with more examples?