Bot implementation / command limits

Hey guys,

I need some help with the sending limitations of commands. I am currently stress testing my bot and I run into an issue which I am not finding a solution for.

Only if additional connections are open an error occurs at one point: | Software caused connection abort: socket write error

which is hinting to me that the connection got closed on Twitch’s end.

The bot is not getting banned so I assume it is not hitting the PRIVMSG limit. Maybe another limit which I am not aware of? Or could being not a known/verified bot an issue?

Here some context:

3 message pools are running.


  • Runs every ~ 330ms
  • handles the sending of authentication and joining messages (NICK, PASS, CAP REQ, JOIN, PART)
  • Is connection independent
  • Every message gets send with the corresponding connection.
  • Maximum 1 message each iteration.


  • Runs every ~ 1530ms
  • Handles the sending of PRIVMSG messages to channels without MODERATOR privilege.
  • Iterates through VIEWER privilege connections and sends 1 message for each connection and iteration.


  • Runs every ~ 330ms
  • Handles the sending of PRIVMSG messages to channels with MODERATOR privilege.
  • Iterates through MODERATOR privilege connections and sends 1 message for each connection and iteration.

Every connection holds only one type of channel (VIEWER, MODERATOR). This is depending on the channel role of the bot. A VIEWER connection holds 90 channels, a MODERATOR connection holds 70 channels at max.

I tried different iteration times and channel limits per connection, but at one point im getting the error.

Any help is really appreciated.



Some possible solutions:

About once every five minutes, the server will send you a “PING”. To ensure that your connection to the server is not prematurely terminated, reply with “PONG”.

Twitch also limits the amount of data sent to and from a single address.

For more info for command & message limitations

1 Like

Once every 300ms amounts to 100 in 30 seconds, which is the current limit for channel moderators. The send limits are per account, so additional connections on the same account having their own independent rate limiting is going to break.

You can also only rely on having the mod limits if you 100% trust the broadcaster(s) using your bot not to unmod it while it’s above the non-mod limit.

1 Like

Thx for the replies.

My bad, i have implemented the PING PONG. I didnt mention it because the error occurs before the first PING arrrives.

You mean other than message/whisper limits? In the test-case the bot sends 100 JOINS and “.mods” commands to get the moderator list of each channel. 245 messages in total.

I am really suprised that the message limit is per bot account. I thought it is per connection. How can you handle (even with verified state) a lot of channels (500+) at the same time? Not that I am in that range, I just want to implement it correctly.

Currently i am kind of working around this by reacting to

:jtv MODE #channel -o user

message and move (part and rejoin) the channel to a connection with VIEWER iteration and the other way around. But it feels not reliable since the bot might react during the transition time and maybe the MODE message is not received or to late.

For some context the writer log of a test-run:

Yes I replaced the channel names with #channelName :wink:.

The link I provided to the command & message limitations are referring to what is being sent from you to the server.

What Twitch doesn’t disclose on their API are their limitations of the amount of data being sent from the server to you.

For example, back when I made a bot a few years ago. I was messing with the API to retrieve the top channels on twitch. By top, I mean the channels with the most viewers and I could only ever join 48 channels before getting disconnected. From there I realized that the disconnection was intentional because when you have twitch sending potentially 100K+ messages/second from chatters that is too much for them to be sending you lol. I am not sure if they raised the limit or not but that is also something to consider when making a bot that might be handling large channels.

1 Like

Funny that you mention this. That was exactly my test case. :joy:. Twitch must have increased the receiving limit. I got the top100 channel messages with a single connection. I dont know if some messages got dropped becasue i didnt receive a massive amount of chat messages.

The error only oocurs if i am adding more connections. So it must have sth to do with my implementation of the sending limits. 3ventic mentioned that the limits are account related. That is really confusing me. How can you handle than >500 channels, if you want to moderate them proper. Even if you are a verified bot there is a ceiling.

JOINs are rate-limited to 50 JOINs per 15 seconds. So you need to spread them out. Big bots like moobot take hours to rejoin on full reboot and usually offer “priority” to donors. I think there are higher limits for verified bots but I do not see that documented anywhere.

It used to be per connection but was changed to per account within the last year due to abuse. I recommend spreading out commands to stay within the limit. For example there is very little reason to run “.mods” when joining a channel unless you need to display the full list. For access control just use IRC v3 tags.


There is an internal buffer on the socket sending data to you. If you fill that buffer because you are not reading messages fast enough that it will disconnect. This is why most people still use multiple connections even after the rate limits were changed to per account.


Thanks for the detailed info and your time guys.

Time to adapt my code.

Sounds good. I was not sure if the MODE tags are send everytime a channel is joined. So i decided to go with the “.mods” command.

Have a nice day

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