What is default timeout value of RestSharp RestClient?
Asked Answered
H

3

64

Anybody aware of default timeout value of RestSharp RestClient ?

Hawkshaw answered 3/3, 2015 at 10:32 Comment(0)
F
89

RestSharp is using HttpWebRequest under the hood, which has a default timeout of 100 seconds.

Fraser answered 4/3, 2015 at 13:34 Comment(0)
P
4

At least some versions of RestSharp (I'm looking at 106.6.10) will use an explicitly set Timeout value when using the async requests, but do not provide a default.

This is because:

The Timeout property has no effect on asynchronous requests made with the BeginGetResponse or BeginGetRequestStream method.

(https://learn.microsoft.com/en-us/dotnet/api/system.net.httpwebrequest.timeout?view=netframework-4.8#remarks)

Plating answered 14/4, 2020 at 20:45 Comment(0)
S
0

Starting from the v107 RestSharp stops using the legacy HttpWebRequest class, and uses well-known HttpClient instead. Timeout option now is obsolete and they recommend using MaxTimeout instead.

Regarding the official documentation:

If you don't set a duration, then a default value is used. The default value is currently 100000 ms (100 seconds).

In addition, if you want to change options there is the next syntax:

        var options = new RestClientOptions("https://api.myorg.com")
        {
            ThrowOnAnyError = true,
            MaxTimeout = 1000 // ms
        };

        var client = new RestClient(options);
Shagbark answered 17/2, 2023 at 14:18 Comment(2)
Oh my god… it’s in milliseconds. Well I spent way too much time on that one... Tip: put 1 * 1000 to make it clear. Or add // msCoadjutress
@Simon_Weaver, done (added // ms )Shagbark

© 2022 - 2024 — McMap. All rights reserved.