Multiple IRC connections

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

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?

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:



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.

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.

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.

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.

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.

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