Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6800031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:55:11+00:00 2026-05-26T18:55:11+00:00

I’m experimenting with the Twitter streaming api, and am trying to open a stream

  • 0

I’m experimenting with the Twitter streaming api, and am trying to open a stream for a user to consume events as they happen. I’m using a standard set of classes for making REST api calls to twitter. When using https://userstream.twitter.com/2/user.json in a “GET” call the response stream never ends… I’m opening a StreamReader and reading the response as I would with any other REST call to Twitter. This is probably obvious to others, but how do I “consume” this stream… Is there a way to read the StreamReader as it’s reading (meaning before it closes)? or maybe there a different method I can user to consume this stream…. again, I apologize if this seams to be elementary to some, but I can’t figure it out at the moment… Thanks in advance for any advise or help!!!

Here is the original source I started troubleshooting this with… This method was fabricated from a set of C# Classes I found in a forum on LinkedIn. At the line that reads “responseData = responseReader.ReadToEnd()” the method starts to “drink” the stream… but does so like a bottomless cup… reading this stream of data in real time before it closes (which is essentially until I stop debugging or kill the process) is the question I’m tackling.

Private Function WebResponseGet(ByVal webRequest As HttpWebRequest) As String
    Dim responseReader As StreamReader = Nothing
    Dim responseData As String = ""

    Try
        responseReader = New StreamReader(webRequest.GetResponse().GetResponseStream())
        responseData = responseReader.ReadToEnd()
    Catch
        Throw
    Finally
        webRequest.GetResponse().GetResponseStream().Close()
        responseReader.Close()
        responseReader = Nothing
    End Try

    Return responseData
End Function

UPDATE & RELATED QUESTION:

So, I figured out the following way to keep a stream open, and write it to a file (this won’t be the final approach, I’m just testing, a developing the best way of doing this 🙂

Private Sub DrinkIt(ByVal webRequest As HttpWebRequest)

    Dim coder As Encoding = Encoding.UTF8

    Dim stream_reader As New StreamReader(webRequest.GetResponse().GetResponseStream(), coder, True, 1024)

    Do While 0 < 1

        Dim w As IO.StreamWriter

        w = File.AppendText(targetFile)

        Dim c(5) As Char

        stream_reader.Read(c, 0, c.Length)

        w.Write(c)

        w.Close()

        w.Dispose()

    Loop

    stream_reader.Close()

    stream_reader.DiscardBufferedData()

    stream_reader.Dispose()

End Sub

This writes the opened twitter stream to a file, and every time I Tweet, Retweet, Delete, Direct Message… and so on… The file grows with a JSON objects appended to the text. I used the Do While 0 < 1 for testing here, because I just wanted to see it working. I see on MSDN StreamReader Constructor Description that the New constructor is supposed to accept a Boolean value for “leaveOpen”, but no such argument allowed when I try to add this to the constructor… Does anyone have a good example of how to do this with forcing and infinite loop or just a better approach than this… I would like to simply read new updates sent each time from Twitter, and address them accordingly? There is obviously a way, I’m just new to the concept of consuming a stream like this with out it being closed.. (**btw, Thanks to Dr. Evil’s suggestion, I was lead in this direction… It’s not exactly what he suggested, but is what lead me here)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:55:12+00:00Added an answer on May 26, 2026 at 6:55 pm

    One remark upfront: The leaveOpen parameter you saw is only present in .NET 4.5 and up

    As to how to deal with the Twitter streaming API:

    • http://www.voiceoftech.com/swhitley/index.php/2010/04/open-source-net-c-twitter-streaming-api-client/
    • http://code.google.com/p/twitterstreamclient/
    • http://www.codeproject.com/Articles/75003/Creating-a-Simple-Twitter-Client-Application.aspx

    The above links lead you to opensource libraries and documentation on how to access the Twitter API (both the streaming API and the REST API) with .NET / C#.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.