# IRC Being Randomly Disconnected

**URL:** <https://discuss.dev.twitch.com/t/irc-being-randomly-disconnected/19807>\
**Category:** Chat and IRC\
**Created:** [January 31, 2019, 7:59am UTC](https://discuss.dev.twitch.com/t/irc-being-randomly-disconnected/19807 "2019-01-31T07:59:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kryptic\_coding](https://avatars.discourse-cdn.com/v4/letter/k/e68b1a/32.png) [@kryptic\_coding](https://discuss.dev.twitch.com/u/kryptic_coding)\
**Post date:** [January 31, 2019, 7:59am UTC](https://discuss.dev.twitch.com/t/irc-being-randomly-disconnected/19807/1 "2019-01-31T07:59:09Z")

</div>

I am trying to JOIN a list of channels through a Python program, and after a few seconds and joining a few channels I get disconnected and the error

> ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

What I am doing is connecting, sending my oauth token, nick and then sending a bunch of JOIN messages. There are less than 50 channels to join so I don’t think I am hitting the JOIN rate limit. Thanks for any help in advance.

---

<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:** [January 31, 2019, 9:19am UTC](https://discuss.dev.twitch.com/t/irc-being-randomly-disconnected/19807/2 "2019-01-31T09:19:26Z")

</div>

50 channels? Thats quite a lot.

Sounds like you are hitting the send buffer limit. Basically you are hitting the “I’m not receiving messages in these channels quick enough and now the queue is too long, bye!”

---

<div class="post-metadata">

**Author:** ![kryptic\_coding](https://avatars.discourse-cdn.com/v4/letter/k/e68b1a/32.png) [@kryptic\_coding](https://discuss.dev.twitch.com/u/kryptic_coding)\
**Post date:** [February 1, 2019, 2:36am UTC](https://discuss.dev.twitch.com/t/irc-being-randomly-disconnected/19807/3 "2019-02-01T02:36:02Z")

</div>

Hi, I fiigured out what was happening - I was trying to join offline streams. Now however after roughly 10-15 mins I just get spammed with empty messages and don’t receive real ones. Could you elaborate more on this buffer limit?

---

<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:** [February 1, 2019, 10:17am UTC](https://discuss.dev.twitch.com/t/irc-being-randomly-disconnected/19807/4 "2019-02-01T10:17:18Z")

</div>

> [@kryptic\_coding](#):
>
> I was trying to join offline streams

Thats irrelevant…

> [@kryptic\_coding](#):
>
> Now however after roughly 10-15 mins I just get spammed with empty messages and don’t receive real ones.

That makes no sense do you have a raw line example of an “empty”?

> [@kryptic\_coding](#):
>
> Could you elaborate more on this buffer limit?

To send data a system creates a queue, you consume that queue, if that queue gets too long your connection will be terminated.

You are ping/ponging actively?

---

<div class="post-metadata">

**Author:** ![kryptic\_coding](https://avatars.discourse-cdn.com/v4/letter/k/e68b1a/32.png) [@kryptic\_coding](https://discuss.dev.twitch.com/u/kryptic_coding)\
**Post date:** [February 1, 2019, 10:46am UTC](https://discuss.dev.twitch.com/t/irc-being-randomly-disconnected/19807/5 "2019-02-01T10:46:28Z")

</div>

I think I fixed my problem (I wasnt appending \r\n to the PONG message), however is there a way to increase the queue length? What is a maximum amount of clients I can connect to? Also thanks for the help 🙂

---

<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:** [February 1, 2019, 11:47am UTC](https://discuss.dev.twitch.com/t/irc-being-randomly-disconnected/19807/6 "2019-02-01T11:47:27Z")

</div>

> [@kryptic\_coding](#):
>
> however is there a way to increase the queue length?

No. If you don’t keep up you get disconnected. Pretty standard on anything real time message-y

> [@kryptic\_coding](#):
>
> What is a maximum amount of clients I can connect to?

Rate limits are covered in the docs here:

> **[Chat & Chatbots](https://dev.twitch.tv/docs/irc/)**
>
> Twitch Chat & Chatbots

The “send buffer” is undocumented in the docs as it’s a thing thats standard in all messaging pipelines

---

<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:** [March 3, 2019, 11:47am UTC](https://discuss.dev.twitch.com/t/irc-being-randomly-disconnected/19807/7 "2019-03-03T11:47:30Z")

</div>

Closed on March 3, 2019, 11:47am UTC

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