Bot Disconnecting

I am using Phantombot and already contacted their support forums and Discord.

The disconnect symptoms:
When turning the bot on and the stream is offline, the bot disappears in 5 or 10 minutes from the chat. When the stream is live and the twitchchat is active, the bot just keeps going like a champ. After a 6 hours stream the bot can be for many more hours in the chat with a dead chat. Eventually during the night it somewhere disconnects from chat. The console does not state anything special, nor do the logs.

The bot does not freeze or anything; the discord feature and the controlpanel keep running when the bot is disconnected from twitchchat. The bot does not reconnect by itself which it should. It requires a manual reconnect by console command to get it back into the chat. Rebooting the bot makes it instantly function again as well, so it looks not to be a temp ban.

Some say I need to request the bot to be whitelisted. Some say it has something to do with connecting from Germany/ The Netherlands where others have had issues lately as well for connecting overseas to twitchchat with a bot.

What can cause the issue? What can solve it? Any help is appreciated :slight_smile:

A log from when a disconnect occurs since last ping-pong. Only the last two lines are repeated, the ping-pong does not occur anymore after the disconnect:

[11-27-2016 @ 17:35:22.361 GMT] Got a ping from Twitch: PING

[11-27-2016 @ 17:35:22.361 GMT] Sent a pong to Twitch.

[11-27-2016 @ 17:35:27.572 GMT] TwitchCache::updateCache

[11-27-2016 @ 17:35:50.580 GMT] ChannelHostCache: Success with TMI

[11-27-2016 @ 17:35:58.338 GMT] TwitchCache::updateCache

[11-27-2016 @ 17:36:08.378 GMT] Dispatched event me.mast3rplan.phantombot.event.discord.DiscordEvent

[11-27-2016 @ 17:36:10.742 GMT] Dispatched event me.mast3rplan.phantombot.event.discord.DiscordEvent

[11-27-2016 @ 17:36:21.259 GMT] ChannelHostCache: Success with TMI

[11-27-2016 @ 17:36:29.238 GMT] TwitchCache::updateCache

We’d have to defer you back to the dev of the bot.

They would have to debug and fix the issue.
Seems the problem is with the bot itself since: [quote=“Z.Ibrahimovic, post:1, topic:8278”]
The bot does not reconnect by itself which it should

Bot Developer here. I agree, but, I seem to recall in the past that there have been some connectivity issues from the EU (Germany, etc) to the WS-IRC servers in the AWS in Oregon - am I remembering that correctly at least? I am looking into the 3rd party library that provides the WebSocket connectivity, but, if there is never a PING from Twitch and the library does not recognize a disconnect (it does from my house at least, when I have lost internet or unplugged the ethernet cable) - it would seem to me that something else is going on. From what I recall in network engineering (I spent 12+ years at Verizon and CenturyLink on the enterprise network side developing software), the TCP connection may not disconnect but may stop sending data - so perhaps, what I should consider is, if I do not see a PING from Twitch that the connection is no longer properly sending data.

The bot should be sending its own PINGs to check that the connection is still alive.

Apologies, have that backwards and did not have the API documentation or code in front of me at the time. I of course meant PONG.

[EDIT] Actually…

About once every five minutes, you will receive a PING from the server, in order to ensure that your connection to the server is not prematurely terminated, you should reply with PONG

Are the IRC API docs wrong? I should expect a PING every ~5 minutes?

My code if it doesn’t get a PING/other message in a timely it’ll send it’s own PING and if no PONG do the restart loop.

Either way, it’s possible for a bot to miss a server ping, which is why if you don’t have a sever ping in a timely fashion you send your own to test if it was a missed ping, or you connection dropped/terminated/whatever.

Twitch docs states:

About once every five minutes, you will receive a PING from the server, in order to ensure that your connection to the server is not prematurely terminated, you should reply with PONG

Source: Chat & Chatbots | Twitch Developers

Interestingly RFC 1459 says that servers don’t have to respond to client initiated PING’s but I’m sure they all do:

Any client which receives a PING message must respond to
(server which sent the PING message out) as quickly as possible with
an appropriate PONG message to indicate it is still there and alive.
Servers should not respond to PING commands but rely on PINGs from
the other end of the connection to indicate the connection is alive.
If the parameter is specified, the PING message gets
forwarded there.

NodeIRC itself uses a cycling ping timer and sends a PING to the Server if it’s not had one for a while. Which is the logical thing to do.

That said, if a bot hasn’t had a server initiated ping, or ANY packer of data, then yeah it’s supposed to reconnect/deal with it how ever it wants.

So to take this topic back on track. It’s a problem with the bot not realising it may have disconnected from Twitch chat, and dealing with that accordingly

1 Like

Barry - thanks for the extra information, like I said, I agreed it was the bot, I have already coded in a timer subsystem to expect back replies from Twitch now and if not, it forces a reconnect in the meantime in hopes that resolves the issue for the user.

Thanks again!

1 Like

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