Limit on JOINs per IP? scaling issue

Hello, I am making a twitch plays bot for a game and have 10k channels for now to join. I have tested the bot in 1000 channels for a few days no problems. Now I upped it to 10k channels (the bot doesn’t send any messages only listens) and the socket will force close randomly.

2020-01-08,12:55:03,ERROR: System.IO.IOException: Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host. —> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

Its nothing to do with pings/pongs I have that taken care of.

I did find this topic here that talks about the send buffer that twitch sends being too big maybe? : Limits on irc channels join?

This seems to be the issue in my mind and how would you got about solving this?
right now my bot its just running under a anonymous justinfan##### from a single IP.
Could I run lets say 1 justinfan#### per 1000 channels?

like justinfan1 joins first 1000 channels
justinfan2 joins second 1000 channels etc…
all from the same IP? Or would each justinfan## have to have a different IP?

But lets say I don’t want to use the justinfan## account anymore and lets say my account is called james.

can I log into james via irc 10 times so there’s one james in each 1000 different channels? or would I need a new account for each 1000 channels like james1,james2,james3 etc?

There’s nothing in the docs that mention this send buffer from twitch or IP limits per users that I could find other than some threads here and there.

Any input is appreciated :slight_smile:

You can have multiple connections from the same IP, this helps even the load and you’ll be less likely to run into disconnects from maxing out the message buffer.

You can use the same Username/Auth token on multiple connections. This is how all large-scale bots work.

That’s because the message buffer is more of a common sense thing with the underlying technology rather than something Twitch specific. If your connection can’t keep up then Twitch aren’t going to just buffer and queue the messages forever for you, it disconnects you, the same as many chat networks if your connections isn’t capable.

As for rate limits, that’s per account. So if you were to create 10 connections using the Login/OAuth for ‘James’ as in your example, they’d share the same rate limits.

1 Like

Thanks that’s very helpful.

It all makes good sense now. I guess I was overlooking the common sense part of twitch buffering messages for me. Sometimes the most basic of things just fly over my head :sweat_smile:

While I’m here I did run into a weird ‘issue’ when I was logged in with my oauth though… Is there any way to disable people gifting subs and items to a bot? When I was testing my bot in a couple 1000 channels it randomly got gifted subs. I feel like others could use them not a bot… (this is why I’m using the anonymous justinfan account)

You can enable the option to “not receive gifts from channels you don’t follow” and then not follow any channels.

Or login as justinfan.

Also limit the bot to joining the channels you need to join rather than “all of them”

1 Like

Ah I didn’t even think about that to stop the subs :slight_smile:

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