Nathan Osman
Nathan Osman

Reputation: 73175

Why is my third Twitter request always timing out?

This is getting annoying. I have an application that is supposed to post status information on Twitter. It is written in C# and uses DotNetOpenAuth for authentication.

I make a status update with the following code:

var the_request = m_consumer.PrepareAuthorizedRequest(status_endpoint,
                                                      m_access_token);
the_request.GetResponse();

The first two status updates always execute flawlessly and virtually immediately.

Then the third one times out. I get an exception of type System.Net.WebException thrown.

No matter what I do, it's always the third request that times out. Any subsequent requests time out.

What is going on here?

Upvotes: 0

Views: 535

Answers (2)

Loki Astari
Loki Astari

Reputation: 264381

Each twitter API has a rate limit.

I see the default rate is 150 requests per hour.
Depends how they implement the throttling but that's about 2.5 requests a minute.

Have you tried waiting 30 seconds between each request.

Upvotes: 1

RameshVel
RameshVel

Reputation: 65877

I assume the_request is a HttpWebRequest. It leads to timeout if the streams are not closed properly. Make sure to close both of your request & response stream after each request

the_request.GetResponse();
the_request.close()

and

   var resp = the_request.GetResponse();
   //your logic to handle to response
   resp.close()

Upvotes: 4

Related Questions