To clarify, I am connecting to the Twitch chat using a WebSocket. Normally, the socket can remain connected for several days without any issues. However, there are times when the WebSocket connection closes, and I need to reconnect.
I am using two connections to join the channels. Previously, I used many more connections (one connection per 200 channels), but all the sockets started closing (This was running smoothly until it had about 10,000 users.), so I reduced the number of connections.
I am managing the reconnection with a queue. Every 500ms, I join a channel, but reconnecting to 40,000 channels at that speed takes many hours.