Bot getting delay when trying to read recent followers - but not my browser

I’m using a bot to try to detect and announce new followers; as many have posted previously, I’m having issues with the bot getting delayed information. Unlike previous threads, however, when I visit the link in my browser ( https://api.twitch.tv/kraken/channels/dmentia_/follows ), it has updated after just a few seconds - but the bot usually takes almost 5 minutes before it gets the new follower information.

I chose to post a new thread because this is a different issue than just a delay on the API, since my browser has no delay, just my bot. I have turned off local caching on the bot as well, without change.

A twitch staff in a previous thread mentioned that follows have a 5 minute cache on the server; however, twitchalerts does not have a delay of 5 minutes (I’ve run twitchalerts and my bot at the same time, and twitchalerts is always many minutes ahead) - how could they be managing this, if the cache is 5 minutes serverside? I also seem to be getting updates to my browser in seconds, rather than minutes, which implies that it’s not an issue caused by twitch server caching. My only thought here is to try polling https://api.twitch.tv/kraken/users/(USER_ACCOUNT)/follows/channels/(STREAMER_ACCOUNT) for each user in the channel … which I assume would be bad to do at any decent interval, since I expect that would result in hundreds of requests per minute per channel (depending on the number of viewers).

I am directly printing out the results and can confirm it’s not a parsing issue, I’m just not getting the new information at all for many minutes. I am also polling the endpoint only once per 61 seconds, because according to previous threads, sometimes polling faster than once per minute can cause delays.

I have tried removing my clientID and version request properties that the bot was sending, and I seem to get the updates the same time my browser does once I’ve done so, but then they are both very delayed. This is using kraken version 2. Is it possible that once per minute is still too much, and it’s sending a cached page because of this (specific to the clientID of my bot)?

As I began writing this, my browser was receiving the updates significantly before my bot, but I spent a few hours troubleshooting as I wrote this and now both my bot and my browser are now very delayed, regardless of whether or not I pass it a clientID and kraken version - though they both seem to be getting the new information at the same time now. Is it also possible that it’s limiting me because of too many requests within a minute from my IP, then?

TwitchAlerts and other alerters space alerts out instead of spamming them all at once. There is no way around Twitch’s server-side caching.

I understand that, but twitchalerts (and ankhbot actually) reliably gets the followers and displays them before my bot does, even with just one follow. If they’re subject to the same 5 minute cache that I am, how is this the case? Spacing out followers doesn’t really explain this.

But that’s not really my main issue, just that my browser will show a new follow many minutes before my bot - outputting the results of the follower URL - will show the updated list. I have no clue how or why this could be happening

is it possible that whatever method you are using on your bot to fetch the data from the api, has built in caching? so basically it caches the result locally and keeps on replying with that instead of the hot data from the server?

A lot of libraries used for HTTP requests have this issue since it’s normally quite useful, so it’s on by default. Check in the docs if there is a way to prevent caching on requests.

Hope this helps

Thanks for the reply, I have turned off caching (I’m using java HTTPUrlConnection) and also made sure to close and reopen the connection each time just in case

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