#1 2022-01-09 17:42:51

wxinix
Member
Registered: 2020-09-07
Posts: 121

mormot HttpGet, how to change connection timeout?

The default connection timeout for HttpGet appears to be 30 seconds.

How can I change this number?  I'd like to make it smaller.

Thanks!

Offline

#2 2022-01-09 20:18:53

tbo
Member
Registered: 2015-04-20
Posts: 353

Re: mormot HttpGet, how to change connection timeout?

Did you mean HttpGet(), then take a look at WGet().
Default timeout is here "HTTP_DEFAULT_RECEIVETIMEOUT: integer = 30000", but you can overwrite it.

With best regards
Thomas

Offline

#3 2022-01-09 23:55:29

wxinix
Member
Registered: 2020-09-07
Posts: 121

Re: mormot HttpGet, how to change connection timeout?

@tbo  Thank you for the heads up.

I am looking at mormot.net.client.HttpGet function, which does not provide a parameter for setting connection time out. Internally, HttpGet ->OpenHttpGet->OpenHttp->TCrtSocket.Open->THttpClientSocket.Create(0)

I understand I can change HTTP_DEFAULT_RECEIVETIMEOUT to a different value, but I really don't want to change that default value.

Is it an intentional design that mormot.net.client.HttpGet does not allow setting a non-default timeout?  @ab  Do you think it make sense to add an extra timeout parameter, so we can use a non-default value?

Last edited by wxinix (2022-01-09 23:56:07)

Offline

#4 2022-01-10 11:44:07

tbo
Member
Registered: 2015-04-20
Posts: 353

Re: mormot HttpGet, how to change connection timeout?

I haven't had any reason to change it yet, so I could be wrong.

In the Unit mormot.net.client I read the following:

/// THttpRequest timeout default value for data receiving
// - default is 30 seconds
// - used e.g. by THttpClientSocket, THttpRequest, TRestHttpClientRequest and
// TRestHttpClientGeneric
// - you can override this value by setting the corresponding parameter in
// the class constructor
HTTP_DEFAULT_RECEIVETIMEOUT: integer = 30000; 

The last sentence of the help can be implemented like this.

Maybe it will help with your problem.

With best regards
Thomas

Offline

#5 2022-01-10 18:14:31

wxinix
Member
Registered: 2020-09-07
Posts: 121

Re: mormot HttpGet, how to change connection timeout?

@tbo  hi Thomas, thank you again.

I ended up using THttpClientSocket class directly, instead of the function HttpGet.

THttpClientSocket has a constructor that allows specifying a non-default time out.

Offline

Board footer

Powered by FluxBB