Auto Disconnect After Arbitrary Number of Joins

I’m making a bot that will need to scale to several thousand channels soon and I am having an issue of the bot instance disconnecting after an arbitrary high number (usually after around 380) of channels are joined. I’m using a queue, joining at a conservative one channel per second.

I am attempting this on the top 1000 Twitch streams simultaneously to prepare. Is there a hidden limit of incoming data I am allowed to receive until I get kicked? I can’t seem to isolate the disconnects to a single source.

I’ll provide more details if someone will find them relevant.

There is a rate limit for the chat servers. See the Command & Message Limit section here: https://github.com/justintv/Twitch-API/blob/master/IRC.md and this article: http://help.twitch.tv/customer/portal/articles/1302780-twitch-irc

There was also some discussion here: Join rate limits on AWS servers

I should elaborate that the only data I am sending at this point are my initial connection and JOINs, but at far less than the prescribed limit of around 3 per second. Right now, for tests, I am merely listening. I do not send any messages whatsoever at this point.

I am getting disconnected from the TMI server. My bot is set to reconnect on such an event. It is not forcing me to leave channels, the server is actually dropping me, which I didn’t see covered in any of the documentation, on forums, or anecdotally.

If this is the case; do you respond properly to pings? They should come fairly fast if you do not send anything but JOINs

If you join a LOT of busy channels, you’ll not be able to keep up with the amount of incoming messages, when this happens you get disconnected.

Twitch just drops your HUGE message send queue.

Adding to what @BarryCarlyon was referencing, Twitch employs a server-side buffer of 20 messages. If you go over this (or more likely Twitch’s servers lag for the slightest of seconds and you’re in a ton of channels) you will overflow the buffer and be instantly disconnected from chat. I recommend sticking to a maximum of 20 channels per connection for this reason.

Thanks, @BarryCarlyon. That’s actually super helpful info that I haven’t found anywhere else.

@night, thanks for that info. 20 channels per connection sounds pretty unreasonable. I’d just like to confirm that when you say “per connection,” you mean per IP address connected to TMI as opposed to multiple bot instances on the same IP? The question sounds ridiculous when I say it aloud, but 20 channels is terribly limiting. Could you recommend a cost-effective method for introducing new servers at that rate?

Nope, he means 20 channels per TCP connection to Twitch. You can have multiple even hundreds of individual connections on the same IP.

@george You’ve all been super helpful. Thanks again! That should be everything I need.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.