#1 2020-11-04 09:12:47

radexpol
Member
From: Poland, Krk
Registered: 2019-11-29
Posts: 116

WinHTTP request to local SOA method freezes

1.

type
  IQueues = interface(IInvokable)
    ['{9857C187-68A2-4F22-823C-75B75F28B45A}']
    function GetQueues(out response: TQueuesCollection): TResponse;
  end;

2.
  with Server.ServiceDefine(TQueues,[IQueues]) do
  begin
    SetOptions([], [optExecInMainThread]).ByPassAuthentication := true;
  end;

3. put button1 in the same application where the interface is started -> TWinHTTP.Get('http://localhost:2080/api/Queues.WorkingHours');  -> application freezes until http request timeouts (why timeouts?)

When I use used component from indy: the idHttp.Get ( ) everything works fine or when I change the interface execution to own thread (removed optExecInMainThread)

Any ideas?

Offline

#2 2020-11-04 17:16:44

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

Re: WinHTTP request to local SOA method freezes

It is as expected.

optExecInMainThread will let the Server thread call Synchronize() to run the method in the main thread.
But at the same time, the main thread is blocked by the TWinHTTP.Get process, which doesn't call Application.ProcessMessages so Synchronize() is blocked.
As such, the server doesn't answer within the timeout period, and an error is reported.

Offline

Board footer

Powered by FluxBB