Streaming Twitter Search using OAUTH authorization and Multiple Instances Issue


#1

Hi All,

                   I am using simple streaming to search for a tweet, And I am using OAUTH auth for the same, as below , All is well untill I run once instance of this code, If I copy the same code in another class and run with same oauth, I get below error , CAN I USE SAME OAUTH AUTH FOR MULTIPLE CLASSES AND RUN IN PARALLEL.  Any help will be appreciated

<<Error - Msg >>
420:Returned by the Search and Trends API when you are being rate limited (https://dev.twitter.com/docs/rate-limiting).
Returned by the Streaming API:
Too many login attempts in a short period of time.
Running too many copies of the same application authenticating with the same account name.

twitterStream = new TwitterStreamFactory().getInstance(); 
twitterStream.setOAuthConsumer("abc", "abcd");
AccessToken accessToken = new AccessToken("xyz, "zyx");
twitterStream.setOAuthAccessToken(accessToken);
twitterStream.addListener(listener);

StatusListener listener = new StatusListener() {
			public void onStatus(Status status) {
				if (status.getUser().getLang() != null
						&& status.getUser().getLang().equalsIgnoreCase("en"))
					try {
						if(status.getText()!= null){
						System.out.println(status.getText());
						}
					} catch (Exception e) {
						e.printStackTrace();
					}
		}

#2

You should be aiming to have single standing connection with the Streaming API, regardless of any combination of user accounts or OAuth.


#3

Taylor,

Thanks for your input, But I am able to run a single connection with the Streaming API , But I have a requirement where I should be able to connect to the streaming tweets in multiple process each working isolated, And I don’t want to do it with separate user/oauth accounts for each process , Is it possible to achieve this using a single oauth keys, But running on multiple process smoothly ?


#4

You should work on changing the requirement instead. Focus on a single, central connection to the Streaming API to collect tweets – it should have no purpose other than to connect and stream tweets. From there, you can do as much multi-process handling of the tweets as you wish – without opening multiple connections.


#5

In our case, We are creating multiple channels each channel pulling data for specific set of keywords, The sole reason of having multiple connection is to have a better performance and faster tweet pulling, Where every channel is assigned a set of keywords. So once again, Is it possible to achieve in OAUTH ?


#6

No, it’s not possible to achieve and would be potentially considered circumventing the rate limits.


#7

I’m not understaind