[IRC] Twitch Chatbot Disconnection Issues

Lately the bot I made in C# is having quite a few issues staying in chat. Even after replying with a PONG after every PING it recieves from twitch. It still disconnects at times.

I was wondering if anyone knew how many time a bot is allowed to send PING requests to twitch’s IRC Servers without it being punished. What’s the limit on this? Is sending a PING request every 15-30 seconds considered ddosing or spamming?

I’d like to know this in advance so I can code in a auto reconnect feature if twitch decides to DC the bot again, but first I’d like to know the specifics on the amount of PING Requests one is allowed to send and with what interval.

Hi,

From my understanding sessions are killed if a client has not sent a message in 11 minutes. The server sends a PING every 5 minutes to keep a connection alive. Timings are subject to change, but 15s is excessive.

Do you mind sharing your connection logic?

Well I’m coding in C# and connecting through TcpClient. I always respond with a pong whenever twitch pings me but for some reason the bot still gets disconnected. I have no idea why this is happening and it’s really bothering me. This wasn’t happening before but it started the past week and a half.

Decided to go with a 2.5 minute ping to check if the connection is still there for now to see how that goes.

Feel free to past a raw log of connections, with oauth garbled.

I have the same issue with IceChat 9.0.6 chat client as well as my own node-js based IRC bot. It really looks like if the timeout settings and the PING interval aren’t synchronized. The server sometimes closes the connection even before sending out a PING (or it appears as such; lag, packet loss?). If I regularly send a PONG without waiting for a PING, everything’s fine.

I’ve had some people have the problem of random disconnects with my chatclient. It only happened when the connection wasn’t active at all (no incoming/outgoing messages for a few minutes), so only in rather inactive chats. I’m guessing their router/internet somehow decided the connection wasn’t needed anymore. One guy switched their router and it didn’t happen anymore. I don’t know if that is your problem as well, but I’m now sending a PING to the server every 45 seconds (if I didn’t send or receive any other messages in that time of course) and that seemed to solve the disconnection issues for a few people.

@tduva_ Yeah, that makes a lot of sense. I did not think that the router could be at fault. I’ll look into this and check if using TCP’s keep-alive fixes the issue.

I’ve been having the same issue with the bot I’m trying to create. It randomly looses connection, and this bot is connected to a 24/7 streams chat room, with constant messages, it seems like all of a sudden it just doesn’t receive anything from the server. Sometimes it could loose connection in a couple hours, other times a few days.

This bot is hosted on a VPS in Atlanta, I have also tried moving it to a dedicated server in another data center resulting in the same issue. I could have the bot auto restart but that has had some of its own issues. I have tried pinging the server every so often, it does reply to every ping it gets, but according to the log it stops receiving anything