7

I'm using a twitter library that uses HttpWebRequest internally to make requests to the twitter API. For some odd reason, the requests sometimes take a lot of time to complete (~10 minutes).

The HttpWebRequest object is not exposed by the library.

Is there any way to specify a global timeout and readwritetimeout for the requests, perhaps via app.config?

jay_t55
  • 11,362
  • 28
  • 103
  • 174
imlokesh
  • 2,506
  • 2
  • 22
  • 26

2 Answers2

3

Unfortunately not currently possible. The constructor of HttpWebRequest has this value hardcoded - reference source.

Iain
  • 10,433
  • 16
  • 56
  • 62
-1

That timeout is in milliseconds - so 2000ms = only 2 seconds.

System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create("URL");
req.Timeout = Convert.ToInt32(ConfigurationManager.AppSettings["timeOut"]);
Req.ReadWriteTimeout = Convert.ToInt32(ConfigurationManager.AppSettings["readWriteTimeout "]);

App.config

<appSettings>
<add key="timeOut" value="200" />
<add key="readWriteTimeout " value="10000" />
</appSettings>

Timeout = time spent trying to establish a connection (not including lookup time)

ReadWriteTimeout = time spent trying to read or write data after connection established