IRC server slow with sending messages to clients

After a while of testing, It seems that there is a big delay in receiving messages sent.

20:24 martmists: !ping
20:24 martmists: !ping
20:24 martmistsbot: Pong!
20:25 martmists: !ping
20:25 martmists: ...
20:25 martmistsbot: Pong!
20:25 martmistsbot: Pong!

It’s likely not my framework, since reader.readline() simply isn’t getting the data even if I don’t do anything with it. Does anyone know why this happens? Or is it just because I have a smaller channel and thus a smaller priority?

Channel size isn’t a factor - I’d suggest to post the section of code dealing with your incoming messages. Odd that you are finding it to be delayed.

Is your bot a moderator? If not, you may just be seeing intentional chat delay that allows moderators time to timeout/ban users before the general public sees the chat. (If you’re already a mod, this wouldn’t apply)

Are your timestamps showing minute:second or hours:minute? If it’s hours:minutes you should include seconds for better measurement.

1 Like

It is moderator already. I’ll see if I can make bttv set timestamps to include seconds, because I literally copied this from chat. For my current code, here is what I’m using for my bot.

Some testing has been done.
Note that the timestamps on my end are created the moment I received it as a PRIVMSG

First of all, I tested the normal offset (first items will always be twitch)

Tue Sep 27 17:00:30 2016
Tue Sep 27 17:00:07 2016

So the normal offset is roughly 23 seconds, good to know. Now I send messages about 4 times in under 2 seconds.
1st message:

Tue Sep 27 17:02:23 2016
Tue Sep 27 17:02:00 2016

Looks on time to me
2nd message:

Tue Sep 27 17:02:24 2016
Tue Sep 27 17:02:30 2016

Strange, it was received 6 seconds after, instead of the usual 23 seconds before.
3rd:

Tue Sep 27 17:02:24 2016
Tue Sep 27 17:03:00 2016

It’s about a minute behind now.
4th:

Tue Sep 27 17:02:24 2016
Tue Sep 27 17:03:30 2016

Almost a minute and a half.

So it looks like twitch sends PRIVMSGs to me about once every 30 seconds?

Weird - have you tried using it in a larger channel? Should be able to determine that way if the delay is originating from Twitch or if it’s something on your side (unfortunately I am not very familiar with Python so I won’t be the most apt person to review.)

Just tested in b0aty’s channel:

Tue Sep 27 17:37:20 2016
Tue Sep 27 17:36:57 2016

Tue Sep 27 17:37:21 2016
Tue Sep 27 17:36:58 2016

Tue Sep 27 17:37:37 2016
Tue Sep 27 17:37:14 2016

Tue Sep 27 17:37:39 2016
Tue Sep 27 17:37:16 2016

Tue Sep 27 17:37:42 2016
Tue Sep 27 17:37:19 2016

Tue Sep 27 17:37:43 2016
Tue Sep 27 17:37:20 2016

Looks fine to me, so I’m guessing this is on twitch’s end

Please remove your client id from the public repository, while it’s public you usually don’t want to pass it around to make it easier to hijack. (Just include it with config.get)

I don’t know Python (I’m a c# guy), so let me ask a question I’ve seen in the past before someone more knowledgeable in that space comes by:

Are you using a library like twisted so your command processing doesn’t block your listener thread? (I see something called async twitch, but that only works if you have the processing happening off the listener)

Removed the Client ID.

The message parsing is all that’s blocking as far as I can tell. (Even though it only takes less than half a second). I’m not using library other than re (python’s regex module)

I don’t know python that well, but you seem to only have a single event loop, which runs all of its callbacks and events on a single thread. Something blocks and everything waits for it.

An event loop runs in a thread and executes all callbacks and tasks in the same thread. While a task is running in the event loop, no other task is running in the same thread.

That’s only if there is something to read.

I’m voting that its something in your code as well, as 3ventic suggests, because the delays you see in b0aty’s channel is still quite larger than I would expect to see.

For example, I went into b0aty’s channel and did the same exercise with my bot and the time stamps are ~1 second apart as one would expect (excluding delay for non-mods, but I think you circumvent that if you are connected via IRC anyways)

My timestamps were 23 off because of my system time being different :stuck_out_tongue:

anyways, I figured out the problem, and after the next push it should be fixed.

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