Running multiple Twitter Streams with the same OAuth credentials


Basically I am just wondering if this is even possible, since I was debugging some code running my app while the user I designed it for was also running it and it caused things to just fail

I am using Ruby’s TweetStream gem to accomplish the functionality. I noticed that when I was trying to refactor some code while the user was testing its functionallity to ensure that it functioned correctly , that the event machine running the code would essentially orphan the stream object and hang in an endless loop. I couldn’t find any documentation explaining why it would do so with the TweetStream gem, so I’m wondering if opening a new stream using the same consumer key, key token, and OAuth key and token is causing twitter to forcibly close the stream for the least recent person to connect.

I haven’t found anything that explicitly says that this will happen but it leads me to believe that it is either an issue with using the same credentials, or that there was an issue with Twitters Streaming API in general tonight. Considering though, that the program appears to work fine when we aren’t trying to run the program at the same time it leads me to believe the first to be the issue


And I answered my own question, just took a look again at the API documentation for reasons disconnects can occur and found that I was correct in my assumption that using the same OAuth credentials will cause it to fail.


Indeed, if you’re providing an application that connects to the Streaming API, we intend that you’ll maintain a single open connection representing your entire service.


So my question is this: I am writing an application that uses the Streaming API and wish to be able to have multiple programs running concurrently from different computers. Would connecting to the public stream using the same consumer key and consumer secret but with a different OAuth signature still cause the oldest Public Stream using the same Consumer key and token to close, or does it close public stream connections based on Oauth signatures?


This is from the streaming API documentation

"Each account may create only one standing connection to the public endpoints, and connecting to a public stream more than once with the same account credentials will cause the oldest connection to be disconnected.

Clients which make excessive connection attempts (both successful and unsuccessful) run the risk of having their IP automatically banned."

My issue is that I am unaware whether the account credentials refers to a user account given with OAuth, which I assume is the case, but do not wish to test too many times due to testing using the same IP and potentially run the risk of becoming IP banned


The word “account” in the streaming API is a little more loaded than with the REST API. The Streaming API is a system where the primary agent of usage is a Twitter account. Its usage is meant such that the account connecting also represents the connecting application – they are to be one and the same.

You should not connect to based on an end-user’s access token – you should just have a single stream representing your application in totality. And regardless of whether you’d want to be running concurrently on multiple machines, you should be just maintaining a single connection from a single machine.


I decided to just say c’est la vie and test the shell version of my application from command line, and it appears to be connecting to the correct endpoint and establishing a connection for each shell I run on different ports, meaning I assume that means it was successful, and that public stream connection termination handling is based on OAuth credentials