# Multiple IRC connections

**URL:** <https://discuss.dev.twitch.com/t/multiple-irc-connections/3466>\
**Category:** Chat and IRC\
**Created:** [September 30, 2015, 12:36am UTC](https://discuss.dev.twitch.com/t/multiple-irc-connections/3466 "2015-09-30T00:36:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![craysiii](https://avatars.discourse-cdn.com/v4/letter/c/d9b06d/32.png) [@craysiii](https://discuss.dev.twitch.com/u/craysiii)\
**Post date:** [September 30, 2015, 12:36am UTC](https://discuss.dev.twitch.com/t/multiple-irc-connections/3466/1 "2015-09-30T00:36:23Z")

</div>

I am writing my own chat client.

I know that to get messages from a certain channel, you have to connect to a certain IP, available via [https://api.twitch.tv/api/channels/channel/chat\_properties](https://api.twitch.tv/api/channels/channel/chat_properties).

I am wondering what the probability of multiple channels having an IP in common is. I would like to use as little connections as possible, but I also want to ensure that my user can get messages from all channels they are connected to. Should I try to group up the IPs from each channel and find a common one, or is that not likely to work? Should I have an IRC connection for each channel? Will having multiple connections mess up anything?

---

<div class="post-metadata">

**Author:** ![george](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/george/32/120_2.png) [@george](https://discuss.dev.twitch.com/u/george)\
**Post date:** [September 30, 2015, 1:12am UTC](https://discuss.dev.twitch.com/t/multiple-irc-connections/3466/2 "2015-09-30T01:12:04Z")

</div>

For most IRC users there are two chat clusters you need to be concerned with: _main_ and _event_. **You can access a particular channel from any server within a cluster to which it is assigned.** Almost all channels will be on the _main_ cluster with the exception of extremely large channels (riotgames) or events (esports, E3, TwitchCon, etc.).

There are various API endpoints you can use to determine which cluster a channel resides on including the one you mentioned above. For example:

Main: [http://tmi.twitch.tv/servers?channel=lirik](http://tmi.twitch.tv/servers?channel=lirik)

Event: [http://tmi.twitch.tv/servers?channel=riotgames](http://tmi.twitch.tv/servers?channel=riotgames)

The `cluster` value will tell you which you need to connect to and the `servers` array will give you a list of IRC compatible servers. (Note: you can also use port 6667)

How many connections you uses depends on how active the channels and bot is. If they are a few smaller channels you can probably group them on a single connection. If you are receiving too many messages on a single connection you might reach the limit of the server’s sending buffer and get disconnected.

---

<div class="post-metadata">

**Author:** ![craysiii](https://avatars.discourse-cdn.com/v4/letter/c/d9b06d/32.png) [@craysiii](https://discuss.dev.twitch.com/u/craysiii)\
**Post date:** [September 30, 2015, 1:32am UTC](https://discuss.dev.twitch.com/t/multiple-irc-connections/3466/3 "2015-09-30T01:32:08Z")

</div>

Thanks for the reply george. I realized that I should just try to connect to a different server for each channel, to avoid the limits you spoke of. Those API links you provided also helped, as they are much more simple to parse than what I was trying to use.

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [September 30, 2015, 10:54am UTC](https://discuss.dev.twitch.com/t/multiple-irc-connections/3466/4 "2015-09-30T10:54:39Z")

</div>

It is worth considering doing some stats tracking, as you might not need to use multiple IP’s all the time for you bot, since it’s generally unlikely that all the channels you serve will be casting at the same time. Which saves you coding.

Some people will run a balancer type thing that will connect additional connections when needed instead. Depends if you are running a single name bot across many channels, or many named bots over many channels.

---

<div class="post-metadata">

**Author:** ![craysiii](https://avatars.discourse-cdn.com/v4/letter/c/d9b06d/32.png) [@craysiii](https://discuss.dev.twitch.com/u/craysiii)\
**Post date:** [October 1, 2015, 10:15pm UTC](https://discuss.dev.twitch.com/t/multiple-irc-connections/3466/5 "2015-10-01T22:15:32Z")

</div>

Makes sense. For now I am writing a strict chat application, but in the future when I do write a bot, I will keep that in mind. However for my current code, it’s just more simple to give each channel it’s own connection, the total amount of connections will be low (I assume). I can’t imagine a user wanted to watch more than a few chats at once.

---

<div class="post-metadata">

**Author:** ![tduva](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/tduva/32/392_2.png) [@tduva](https://discuss.dev.twitch.com/u/tduva)\
**Post date:** [October 2, 2015, 8:51pm UTC](https://discuss.dev.twitch.com/t/multiple-irc-connections/3466/6 "2015-10-02T20:51:30Z")

</div>

Be careful with those kinds of assumptions though. I have some users joining 30 channels or more on startup with my chat client. Depends on whether it’s a more standalone chat client or directly tied to watching a stream.

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [November 1, 2015, 8:51pm UTC](https://discuss.dev.twitch.com/t/multiple-irc-connections/3466/7 "2015-11-01T20:51:43Z")

</div>

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