Increase in 420:Enhance your calm



Awhile back I wrote some software to monitor twitter accounts for my company. I used Tweetinvi. I recently performed some upgrades relating to allowing users to manage which accounts are being monitored. However when I went to redeploy the service I found that I keep getting 420 errors when my streams start. And even if a stream doesn’t get a 420 no tweets seem to get through (I think that means I’m being rate limited somehow). I did try using different authentication keys but that did not help.

Has there been any reason posted for an increased rate of 420s?


Have you found out anything since you asked this? I am in the exact same position as you, and I haven’t even realized that there was a problem until recently. My temporary solution is to just use get/search (REST) to gather tweets every day at 7am for the past 2 days, which seems to work surprisingly well, but it is basically against the recommended method of gathering tweets over long periods of time (=use Stream).


How many streams are you trying to connect? The 420 error is most likely to be caused if you are being rate-limited for stream connections (see the sections on Reconnecting and Connection churn in the Streaming docs)


Hey. I looked around the forums and found another relevant thread (link: Sudden increase in 420 (Exceeded connection limit for user) responses from Streaming API ) in which someone was using Tweetinvi and had similar problems. Problems appeared for me after updating the library, as well as after doing some tweaks to my system. Here is what I think happened and how I fixed it:

[the function calls mentioned from here on forth are within the Tweetinvi library in C#]
I was actually starting multiple Streams using different credentials, but in the same application as a result of implementing this feature without proper testing and I was using Auth.ApplicationCredentials rather than Auth.UserCredentials. Since Tweetinvi is using some kind of global Authentication settings, it turns out that what I thought was multiple credentials being served to each stream, I was overwriting the credentials every time I started a new stream, which is why the streams connected properly the first time, but then always gave 420 errors at reconnect (They were reconnecting on the last credentials being input). I solved this by setting the thread credentials using Auth.SetCredentials(), to the credentials I thought should be the thread credentials (but weren’t), just before starting each stream, and now reconnections seem to work. I will test this further, hopefully it works as I described.

My fault was to assume that my code is perfect and that the bugs were on Twitter’s side… :smile: sorry about that

Anyway, I’m still going to keep the REST daily search, until I am sure that the system actually works and there are as few missed tweets as possible. (and keep it under the rate limits)

Thanks @andypiper for prompt replies!