63

Anybody aware of default timeout value of RestSharp RestClient ?

0

3 Answers 3

88

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

0
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)

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);
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 // ms Mar 14 at 1:19
  • 1
    @Simon_Weaver, done (added // ms )
    – Viktor
    Mar 20 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.