Is it possible to set timeout for TXDataWebConnection?

Hi,
Question like in topic.

You can try using the OnRequest event?

procedure TForm1.XDataWebConnection1Request(Args: TXDataWebConnectionRequest);
begin
  Args.Request.Timeout := 5000;
end;
1 Like

Thx is working but in Core can I use anonymous procedures like this ?:

webConnection.onRequest:=procedure(Args: TXDataWebConnectionRequest)
  begin
    Args.Request.Timeout := 5000;  
  end;

but i get an error:
[Error] ModuleWeb.pas(260): procedural type modifier "reference to" mismatch

I don't know much about an anonymous procedure, someone else will have to help there.

You can define a procedure normally and then assign it, if you're creating XDataWebConnection at runtime for example.

webConnection.onRequest := XDataWebConnection1Request;

Note that this is used for every new request to XData, and is usually used to add the JWT to an authorization header, so it might be that a normally-defined procedure would be workable?

@brunofierens could you answer concerning anonymous methods?

Afaik, this must be a pas2js limitation to specify an anonymous proc as event handler this way.