-
-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error with Twitch integration when updating #101488
Comments
Hey there @joostlek, mind taking a look at this issue as it has been labeled with an integration ( Code owner commandsCode owners of
(message by CodeOwnersMention) twitch documentation |
Hi, very same issue here, also with HA 2023.10.0. |
I'm also receiving the error, I figured I'd be hitting this with my 200+ channels I follow (most of which haven't been online in ages, forgot that I followed). After enabling debug logging for about 5 minutes I get a 300+mb debug log 🫠. I also saw that the OP has I think the problem is throttling, from the debug it's clear that is occuring:
I also see this where the
AFAIK each channel is updated every minute, the normal frequency for sensor updates. I can also confirm, that "reloading" the integration fixes it temporarily. I imagine it's re-creating the session that has it's throttle reset. I see similar stack traces in the OP in my logs, but I am pretty certain that's a result of not catching a case where the The second error where the connection is outright refused, I am also pretty certain is due to throttling, but since the API doesn't respond, there might be a case where the client doesn't know why it can't connect and defers to throwing a generic |
I have the same problem and I only follow 27 channels. It works for an hour or few hours and then stops updating. |
Is a bearer token used when contacting the API? In their API documentation they mention up to 800 calls pr minute if a bearer token is provided with the call. |
Yes, we use a bearer token. But we're doing more requests for one channel. I will try to optimize this and split out the current sensor into more sensors before the next release as I think this is the only way to proper fix this. |
How many calls pr channel is it making? Searching for a solution I found a thread saying disabling pooling and creating an automation to update using |
It will probably come down to making the calls more efficient, like the get-streams API, instead of sending a single login name you can query up to 100 at a time. And since the max people you can follow on twitch is 2000 I believe, the calls definitely need to be more efficient/robust. |
I am running into this with only 4 channels that I follow, so it does not look like an issue that only appears when following a lot of channels. @joostlek Thanks for looking into it ❤️ |
Chiming in: I disabled polling on the integration and set up an automation to poll 2 channels every 5 minutes. It still failed. Strangely enough, it starts working again after a reload, as if it got stuck on something that's not rate limiting. (Is it not refreshing auth tokens properly or something? ...) Going to try scheduling an automated reload of the integration to see what that does... Update: Regularly reloading the integration, combined with the more limited polling, indeed appears to make it work. |
How do you do that? |
Create an automation with a time pattern trigger, and in the actions add a call to "Home Assistant Core Integration: Reload config entry" and select the Twitch channel entity you want to be updated. (I'm not sure if a single reload call is enough to reload the entire integration or if you need one for each channel. Since I'm only monitoring 2 channels, I just added a call for each.) |
I do it that way now, every hour. Still get around 1k errors. I do follow 9 channels. |
How frequently are you polling them? (I poll 2 channels every 5 minutes, and reload the integration every hour, with no errors.) |
I didn't change something. What's the default? And where can I change it? |
Funnywise had the Same error and was reading here also. Since i made an Account on Twitch ONLY for the Integration and all works it without Problems with around 15 Entities. |
I am having this issue as well.. It continues the last 11 lines, over and over again. My last log had over 2414906 lines of errors. 2023-10-22 19:50:43.307 DEBUG (MainThread) [homeassistant.components.twitch] User is not subscribed The above exception was the direct cause of the following exception: Traceback (most recent call last): |
+1. I have many subscriptions, but all but 2 are disabled. Still failing every 30 seconds on those 2. |
If this is throttling related, a more robust approach may be to implement a "push" model using webhooks: |
I get baffled how some simple integrations go into the HA Core and are broken for months (or "since forever" as can be seen by the amount of integration bugs abandoned here) and some other very complex integrations and almost flawless end up in HACS as "secondary citizens", such as LG devices. At the start, I thought naively there would be a "promotion process" of some sort to move in-dev integrations from HACS into the Core once they're considered useful and stable... but now I see it's just a matter of where the person is comfortable coding and allowed to do PRs (or leaving bugs). I know this is open source and all, not to shoot the |
Yeah It's broken in my instance too same issue, hopefully it gets fixed soon |
Does this still happen at the moment? Something major has been fixed in a 2023.3 hotfix |
Actually, it seems to be fixed... |
Fixed for me as well for now. However, I think it would take a while for the issue to crop up so best to give it at least a few days to confirm. |
I'm running it for several days now and everything seems OK. I have 30 followed channels and all are updating correctly. |
I had the Twitch HA Integration disabled myself because my plugin showed too much nonsens due to the bug in the Integration. When you guys says it might be fixed then I will try again. Hope it works again. It was really useful before for me. And thanks for the update :) |
I'll close this issue then |
I just thought I'd say that I haven't had any issues since the fix. Thanks @joostlek! |
The problem
Hello,
I have successfully connected the new Twitch integration on 2023.10 and at the time of integration, all my followed channels were retrieved with the correct status (streaming/offline).
However, since yesterday, they haven't updated. Checking the logs I have the following:
After enabling debug logging I also found this (it repeats for each account I follow):
What version of Home Assistant Core has the issue?
core-2023.10.0
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Container
Integration causing the issue
Twitch
Link to integration documentation on our website
https://www.home-assistant.io/integrations/twitch/
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: