#1 2018-02-12 14:24:42

pvn0
Member
From: Slovenia
Registered: 2018-02-12
Posts: 210

Regarding Sample 04 - HTTP Client-Server

Hi!

I'm new to the MoRMot framework and I have a question to ask.
After I've started the server and I connect with the client(localhost), there seems to be a 1 second deadlock everytime a request is sent to the server(localhost) and I'm not entirely sure why.

I've debugged it using Delphi XE7 32bit and the lock happens in SynCrtSock.pas

procedure TWinHTTP.InternalSendRequest(const aData: SockString);
   ...
   ...
   WinHttpAPI.SendRequest(fRequest,nil,0,pointer(aData),L,L,0)
   ...
   ...
end;

It feels like it's spinning up a new thread everytime or something, I've noticed this in other examples as well. Also tested on another computer (Win8-64).
Not knowing much about the framework as I just started learning it, I am fairly certain I'm just missing something here so would be grateful if somebody could point it out.

Cheers

Offline

#2 2018-02-12 14:36:52

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

Re: Regarding Sample 04 - HTTP Client-Server

No, there is no thread created, the WinHttp API just always waits a little internally, probably for security reasons.

If you use the plain socket client, you won't have this delay.
This is a Windows WinHttp "feature", I'm afraid...

Offline

#3 2018-02-12 17:08:42

pvn0
Member
From: Slovenia
Registered: 2018-02-12
Posts: 210

Re: Regarding Sample 04 - HTTP Client-Server

Thanks, that solves it, I need to do some more reading on this.

Offline

#4 2019-02-21 13:28:52

pvn0
Member
From: Slovenia
Registered: 2018-02-12
Posts: 210

Re: Regarding Sample 04 - HTTP Client-Server

this thread was linked in https://synopse.info/forum/viewtopic.php?id=4899 and I realized I forgot to update on what happened.

In short, the problem had to do with server failing to register url because I didn't run the server executable as administrator at least once (as recommended by documentation if using useHttpApiRegisteringURI). If you haven't registered URL you won't really get any errors unless you are running the server sample under debugger, instead it auto drops to using sockets. Somehow this causes delays when using the client sample, if the server url is registered properly then everything works great as expected.

Offline

Board footer

Powered by FluxBB