63

Anybody aware of default timeout value of RestSharp RestClient ?

theGeekster
  • 6,081
  • 12
  • 35
  • 47

3 Answers3

88

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

Todd Menier
  • 37,557
  • 17
  • 150
  • 173
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)

starwed
  • 2,536
  • 2
  • 25
  • 39
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
        };

        var client = new RestClient(options);
Viktor
  • 380
  • 5
  • 14