66

Anybody aware of default timeout value of RestSharp RestClient ?

0

3 Answers 3

90

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

Sign up to request clarification or add additional context in comments.

Comments

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)

Comments

2

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 Comments

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
@Simon_Weaver, done (added // ms )

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.