Hi

Hi,

How can I set TRestRequest.Timeout ? default value (30 000 milliseconds) keeps beeing used even when changing the value...

Looks like timeout is hardcoded somewhere.

Comments

  1. Stéphane Wierzbicki I'm not aware of the TRestRequest class, isn't it possible to subclass and replace the 30 sec value?

    ReplyDelete
  2. Marco Cantù thank you for the info. Hope that will be fixed for all platforms.
    Dorin Duminica I have directly patched unit System.NET.HttpClient.Win by modifying TWinHTTPRequest.CreateHandles(const AURI: TURI) procedure. I've added this call at the begining of the method :

    Begin
    if not WinHttpSetTimeouts(TWinHTTPClient(FClient).FWSession,HTTP_DEFAULT_RESOLVETIMEOUT,
    HTTP_DEFAULT_CONNECTTIMEOUT, HTTP_DEFAULT_SENDTIMEOUT, HTTP_DEFAULT_RECEIVETIMEOUT) then
    raise ENetHTTPRequestException.Create(SysErrorMessage(GetLastError));
    ....
    End;

    For "simplifications", HTTP_DEFAULT_CONNECTTIMEOUT, HTTP_DEFAULT_SENDTIMEOUT and HTTP_DEFAULT_RECEIVETIMEOUT are declared as global variables set to 0.

    ReplyDelete
  3. Stéphane Wierzbicki Hope you're not planning on using it for anything fancy, given that it disconnects after each request.

    ReplyDelete
  4. Asbjørn Heid​ I'm connecting to RESTFull webservices and only fetching or posting some JSON data.

    ReplyDelete
  5. Stéphane Wierzbicki Yea just keep it in mind if you're using https, especially over the internet. You'll be limited to 1-2 calls per second.

    ReplyDelete
  6. Asbjørn Heid I wasn't aware of this. Thank you for pointing this out.

    ReplyDelete
  7. Stéphane Wierzbicki I learned the hard way, had every thing set up to access Gmail via REST, with OAuth 2.0 authentication and all, but it was just soo sloow accessing the mails. I then found the culprit as mentioned...

    So for those use cases the components are unfortunately utterly useless.

    ReplyDelete

Post a Comment