#1 2023-08-16 07:46:15

sgavrilov
Member
Registered: 2019-05-24
Posts: 20

TRestHttpClientWinHTTP vs. TRestHttpClientWinSock

Hello,

I am confused about which client to use in the Windows environment.

I do not need bidirectional functionality of sockets. The mORMot framework SAD 1.18 says on page 332:

As stated above, there is still a potential performance issue to use the direct TSQLHttpClientWinSock
class over a network. It has been reported on our forum, and root cause was not identified yet.
Therefore, the TSQLHttpClient class maps by default to the TSQLHttpClientWinHTTP class. This is
the recommended usage from a Delphi client application.

However, in the mORMot 2 source code the TSQLHttpClient class maps by default to the TRestHttpClientSocket and there is a note reagrding "slower and less stable" in the source code (mormot.rest.http.client.pas):

{.$define CLIENTUSEWININET}
// force HTTP/1.1 RESTful JSON default mORMot Client class to use WinHttp
// - e.g. to try Windows built-in proxy settings
// - but is slower and less stable in some context (e.g. useHttpAsync)

Please, help me to sort this out.

Sergey

Offline

#2 2023-08-16 09:29:15

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,707
Website

Re: TRestHttpClientWinHTTP vs. TRestHttpClientWinSock

The comment means that we found out that WinHttp client performance was lower than the plain socket client class.

For bidirectional, i.e. WebSockets, there is a single client class, named THttpClientWebSockets from mormot.net.ws.client.pas, which is socket-based.
So no question asked, you don't have the choice - just this class.

Note that the async server did not exist in mORMot 1, and seems to scale better than http.sys from our tests.
Up to a few hunderths clients. For thousands of concurrent clients, switch to Linux for epoll API support.

Online

#3 2023-08-16 11:07:26

sgavrilov
Member
Registered: 2019-05-24
Posts: 20

Re: TRestHttpClientWinHTTP vs. TRestHttpClientWinSock

Thank you for the reply!

As I mentioned, I do not need bidirectional. So, I do actually have a choice. smile

As far as I can understand, the recommendations have been changed and the THttpClientWebSockets is the way to go now.

Offline

#4 2023-08-16 11:34:40

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,707
Website

Re: TRestHttpClientWinHTTP vs. TRestHttpClientWinSock

Indeed.

THttpClientWebSockets is the way to go now. Especially since we now have native TLS support on Windows via SChannel.

Online

#5 2023-08-31 03:18:56

keinn
Member
Registered: 2014-10-20
Posts: 105

Re: TRestHttpClientWinHTTP vs. TRestHttpClientWinSock

strange thing, THttpClientWebSockets randomly close, and very hard to detect/debug.
both with our mormot wsserver ,or third party wsserver,

already turn on the heartbeat by :
WSClient.Settings^.HeartbeatDelay :=10000;

Last edited by keinn (2023-08-31 03:22:45)

Offline

#6 2023-08-31 11:24:20

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,707
Website

Re: TRestHttpClientWinHTTP vs. TRestHttpClientWinSock

Try to put the logs in verbose mode, then look at them.

You could send them to me too if needed.

Online

Board footer

Powered by FluxBB