tmijs / tmi.js

💬 Javascript library for the Twitch Messaging Interface. (Twitch.tv)
https://tmijs.com
MIT License
1.54k stars 216 forks source link

Question: How many channels can a TMI.js instance keep open? #452

Closed ghostzero closed 3 years ago

ghostzero commented 3 years ago

Are there actually benchmakrs how many channels can actually be can be connected to a TMI.js instance? I have a client here that has a few thousand clients in it.

Also, can you make the join queue/handling faster? I have a verified chatbot on Twitch which can make 2000 join attempts per 10 seconds per user.

Server configuration

AlcaDesign commented 3 years ago

Channels don't have to be kept open. You're just telling Twitch to send you data for a channel. There's only one socket connection. The limit is basically how quickly your connection and the code can read in data. If it buffers too much on Twitch's side then they will drop the connection. I don't have any benchmarks for this. You also need to ensure you don't send too quickly per connection. A balance must be struck, however you can send messages to any channel without joining the channel so you could send via clients with no channels connected.

v1.7.x allows you to set the autojoiner delay as low as 300ms (the standard rate) https://github.com/tmijs/tmi.js/commit/dc9495e5de377f329e0f944614741c6c82e7daef (See the release page for other changes) Set options.joinInterval in your options object.

new tmi.Client({
    options: { joinInterval: 300 }
});

If you'd like you could submit a PR to read the minimum from an instance property like this._joinIntervalMinimum = 300;. Then you could modify that before calling connect.