-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
intermittent pyhtcc.pyhtcc.UnauthorizedError #14
Comments
How long were you logged in with the same session/object before it happened? I wonder if the token times out or something. |
I re-login once every 24 hours. I poll the TCC website once every 10 minutes between logins. This failure happened on the 4th day of running, approximately 14 hours since the last login. Do you re-login every minute? |
(See next comment) |
Deleting the comment i just made since its wrong. In the worst case, i would login every minute. I actually only login if something changed from the control-side. If i change something via the webui or manually, it wouldn't know so it wouldn't login again until a planned schedule change happens. In total i actually login only a few times a day. |
OK, I'll reduce my re-connect time from 24 hours to 8 hours and see if that resolves the issue. As I noted above, this is new behavior or a new failure message since about July of this year, so something must have changed on the TCC server side or the manifestation of this failure with the python code. |
Hopefully it helps out. |
updated, it failed again today, 6.3 hours since last login, I'm halving the login interval again to see if it helps. |
I don't think the login interval is going to fix my issue, I've reduced it down to 4.0 hours in between logins and still see the authorization errors, in the last run it occurred 1.2 hours after the last login. How often are you polling the TCC site? That's the next knob I will experiment with. I'm currently polling every 10 minutes. |
I poll on the temperature change in the schedule. So I have a Google Sheet with times and temperatures. It polls that sheet every minute. If the time passes a timestamp on the sheet, it sends commands to match what that interval says and with that creates a new PyHTCC object to do the updates then moves on. A special case is it skips updating if the last timestamp event is the same temperatures as this one (it caches that locally). In total it logs in maybe 6 times a day max in the worst case with a lot of temperature changes. On each of those logins it does it's actions all within a minute before throwing out the object. This allows me to manually change the thermostats and know that eventually the schedule will kick in again but not immediately overwrite what I did manually. |
@csm10495 so are you only hitting the TCC site about 6 times a day? In my case I'm hitting the TCC site every 10 minutes (144 times a day). |
Yep. For fun I pickled a |
anyone know how often a Honeywell thermostat talks to the TCC web site? I'm wondering if I'm hitting TCC too often with my script and triggering the AuthErrors as some type of DDOS defense |
No idea. I'm guessing it long polls or something like that. For fun I'm running:
and they all passed. So I didn't hit anything at least yet. |
Did the same thing 1000 times, to no issue either. I figured that would hit something but I guess not. |
thanks for the data, to precisely replicate my issue please try calling get_indoor_temperature_raw() on at a 5 or 10 minute interval. It's a slightly different POST message than the one you tried. For me it's been failing within 2000 calls. |
I left something running overnight to see if I'd hit the same issue. I hit a network issue at some point:
but nothing like you're hitting. I'll leave it longer and see if something happens. Though if it does, not sure how much we'll be able to do about it at the base level. We'll see. |
After 245 iterations (at 5 min apart), got a:
It was a 200, though was an html response instead of json. Inside the html we have:
So i guess it worked till then, then failed with an unrelated error. I'll try again and ignore |
I catch that intermittent error and a few others and try to recover by re-authenticating using this overridden function:
|
This time at 264 iterations (22 ish hours) i hit the issue you get. html body matches up:
Maybe the solution is to just re-authenticate on a 401. Going to try some more experiments. Edit, forget to mention: Nothing useful in the headers/cookies either. |
Another time at 116 iterations, I got a
With a 500 status code. .. which is kind of funny. Still nothing interesting in cookies/headers. I could sort of see a case where maybe we retry on 500s since it denotes that the server side had an error, but since it isn't a 4XX that our request would still be likely valid. I'll do some more testing. |
I started writing a way of handling retries. Then I hit an issue with it.. tried fixing it and realized I didn't like the way I was doing it. I'm going to come back to this in a bit and probably use the (My way worked for around 800 5-minute-separated requests.. then failed in a way I didn't think of that invalidated the approach. Before that I was failing around 200.) |
I have been seeing intermittent failures for pyhtcc.pyhtcc.UnauthorizedError since July 2023, maybe an artifact of changes made in 0.1.53. Traceback is below:
Sometimes the error is preceeded (triggered?) by one or more pyhtcc.pyhtcc.NoZonesFoundError exceptions (see below).
Is anyone else seeing these errors?
The text was updated successfully, but these errors were encountered: