Jump to content

Karbot

Members
  • Content Count

    3
  • Joined

  • Last visited

Community Reputation

0 Neutral
  1. It's <1ms but it is using ipv6. Another pointer in that direction. Thanks
  2. Many thanks to your answers. I will investigate them. The IPv6 approach seems pretty logical to me. I will have a look at that first and let you know. Maybe there is a switch in the rest libary to set the SocketFamily. Regards Karbot
  3. Hello folks, We're having an issue with local requests. They take much longer than external API calls. It's just a simple GET to the API and it's not reproducible with any other RestClient written with C# or Python. PASCAL/Delphi is not my native language, so I hope to find help here. Please see the timing behavior and code used below. Kind Regards karbot https://<external_hostname> (26ms) https://<external_ip> (168ms) https://mypc (6049ms) https://192.168.178.102 (24ms) https://localhost (2029ms) https://127.0.0.1 (26ms) function TAPIConnector.SendApiRequest(const aURL, aOperation: string; aSetApiParams: TProc<TRESTRequest>; aRaiseException: Boolean): TRESTResponse; begin var restClient := TRESTClient.Create(aURL); try restClient.RaiseExceptionOn500 := aRaiseException; var restRequest := TRESTRequest.Create(restClient); restRequest.Client := restClient; restRequest.Method := TRESTRequestMethod.rmPOST; restRequest.Resource := aOperation; if (Assigned(aSetApiParams)) then begin aSetApiParams(restRequest); end; Result := TRESTResponse.Create(nil); try restRequest.Response := Result; restRequest.Execute; if aRaiseException and not Result.Status.Success then begin const cInvalidSession = 'No valid session GUID'; if Result.Status.ClientErrorUnauthorized_401 and Result.StatusText.Contains(cInvalidSession) then begin raise Exception.Create(aOperation); end; var msg := Result.ErrorMessage; if msg.IsEmpty then begin msg := Result.StatusText; end; raise Exception.Create(aOperation + msg); end; except Result.Free(); raise; end; finally restClient.Free; end; end;
×