[twitter-dev] Streaming API timeout issues

2011-05-19 Thread yippanion
Hi
I'm trying the following code snippet to connect to your API but it is
timing out while waiting for the response.
string url = http://stream.twitter.com/1/statuses/filter.json?
follow=12;
WebRequest req = WebRequest.Create(url);
req.Credentials = new NetworkCredential(ConnectTweetPRO,
Preston71);
WebResponse response = req.GetResponse();
Encoding encode = Encoding.GetEncoding(utf-8);
var responseStream = new StreamReader(response.GetResponseStream(),
encode);
int count = 0;
while (!responseStream.EndOfStream  count  2)
{
DateTime end = DateTime.Now + TimeSpan.FromSeconds(60);
while (DateTime.Now  end)
Thread.Sleep(1000);
Response.Write(responseStream.ReadLine());
count++;
}
Can you help please? I'm sure I'm missing something.
Ta

-- 
Twitter developer documentation and resources: https://dev.twitter.com/doc
API updates via Twitter: https://twitter.com/twitterapi
Issues/Enhancements Tracker: https://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
https://groups.google.com/forum/#!forum/twitter-development-talk


Re: [twitter-dev] Streaming API timeout issues

2011-05-19 Thread Arnaud Meunier
Hey there,

Please be careful when you share pieces of code on this Mailing List. I had
to reset your Twitter password because you just shared it publicly. Please
go to http://twitter.com/account/resend_password so we can send you password
reset instructions.

Concerning your issue, the Streaming API doesn't timeout. Our servers hold
the connection open indefinitely. Cf this documentation page for more
information: http://dev.twitter.com/pages/streaming_api_concepts#connecting

Looks like you're disconnecting in your while loop. There are a couple of
resources out there (like this Shannon Whitley's blog post:
http://bit.ly/ghavU1) that might help you to build your Twitter Streaming
API Client :)

Hope that helps,
Arnaud / @rno http://twitter.com/rno



On Thu, May 19, 2011 at 10:12 AM, yippanion yippan...@hotmail.com wrote:

 Hi
 I'm trying the following code snippet to connect to your API but it is
 timing out while waiting for the response.
 string url = http://stream.twitter.com/1/statuses/filter.json?
 follow=12;
 WebRequest req = WebRequest.Create(url);
 req.Credentials = new NetworkCredential(ConnectTweetPRO,
 Preston71);
 WebResponse response = req.GetResponse();
 Encoding encode = Encoding.GetEncoding(utf-8);
 var responseStream = new StreamReader(response.GetResponseStream(),
 encode);
 int count = 0;
 while (!responseStream.EndOfStream  count  2)
 {
 DateTime end = DateTime.Now + TimeSpan.FromSeconds(60);
 while (DateTime.Now  end)
 Thread.Sleep(1000);
 Response.Write(responseStream.ReadLine());
 count++;
 }
 Can you help please? I'm sure I'm missing something.
 Ta

 --
 Twitter developer documentation and resources: https://dev.twitter.com/doc
 API updates via Twitter: https://twitter.com/twitterapi
 Issues/Enhancements Tracker:
 https://code.google.com/p/twitter-api/issues/list
 Change your membership to this group:
 https://groups.google.com/forum/#!forum/twitter-development-talk


-- 
Twitter developer documentation and resources: https://dev.twitter.com/doc
API updates via Twitter: https://twitter.com/twitterapi
Issues/Enhancements Tracker: https://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
https://groups.google.com/forum/#!forum/twitter-development-talk