Suddenly getting 420 on sample stream

streaming
twython

#1

Hi Folks,
I’ve been running a little bot (@nixiebot) for about a year that has one connection to the sample endpoint and one to a filter endpoint, both via TwythonStreamer objects. The sample is just used to display random tweets on a neon display in my workshop, the filter is used to receive commands from twitter users.

About two days ago I started getting constant 420 errors on the sample stream. The filter stream appears fine. I back off exponentially to a maximum of 32 mins waiting time by putting a sleep in the on_error() event and this appears to have worked in the past.

Is there a problem with the sample stream?

Or, for that matter, have I misread the API policy? I thought it was: “only one connection per endpoint per app at a time”, is it really “only one endpoint connection per app at a time”? I appear to have been getting away with one connection to each endpoint from the same app for a long time if so!

Cheers,
Robin.


#2

Mild bump … Can I have any “official” input on this?
I still think "Each account may create only one standing connection to the public endpoints."
is a little ambiguous, if only in the light of my previous long standing experience of apparently being able to get messages from both sample and filter endpoints at the same time on one app. Was I just lucky or has something changed recently?

Cheers,
Robin.


#3

How often have you been reconnecting to the streaming endpoint? I’ve often seen an IP being blocked after connecting too quickly too many times.

I’ll see what we can do to clarify the language, but the public streaming endpoints certainly only support a small number (one or two) connections concurrently per IP/app/user.


#4

Mostly connections are up for days or weeks at a time with occasional bursts of terminations then re-connections a minute or so later as I load new code and have to debug it. I’ve seen rate limits before when I’ve been in a particularly churning debug cycle (especially if it crashes without closing streams down properly) but they went away after half an hour or so, this one seems to have stuck!

I’m not sure if it’s an IP ban as I can successfully use either stream or filter now, just not both at once (though I haven’t tried both at once for a few days).

Two connections would suit me fine, so is a “small number” one or two? I understand the need to be vague on limits at times to prevent gaming but surely “one or two” could be pinned down? :wink:

The use case of one connection per type of public stream can’t be that unique can it? Especially in the realm of art bots where “observing the twitter zeitgeist” via the sample stream at the same time as using filter for command input seems, to me, to be not that unreasonable.

Anyway I fully understand that this is a marvelous service provided for free and I have no right to demand anything, thanks for letting me do what I’ve done so far!

Cheers,
Robin.


#5

FYI I’m now successfully running two stream connections at once again (one to filter one to sample).
The only relevant thing I changed in the code was upping the maximum backoff time between connection retries from 30 mins to 2hrs.

After the last restart of my bot, on Friday, I was still getting immediate 420 on the second stream I tried to open. I left it running and, on checking in today, both streams are happy.

So my tentative theory is that my previous maximum of 30mins backoff time was too short. Either that or something has changed server side again.

Cheers,
Robin.