-
Notifications
You must be signed in to change notification settings - Fork 155
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
Query params lost when retrying a request on token expired #453
Comments
I believe we actually want to pass the entire context to the recursion: return self._tuyaplatform(uri, action, post, ver, True, query, content_type) |
Thank you for confirming the bug and opening an issue.
I see that the retry request is now formed properly with all the query params (at first sight) but still it returns a new error now: 1004 sign invalid. |
Thanks @ndlarge - Does it ever start working again? If so, do you see anything different in the logs when it starts working? |
Oh yes, on the next cron run it works as if nothing's happened, gets a new token, most of the time it succeeds to get all the fetches intact but every few hours it gets this 'token invalid' error on a random fetch, then 'sign invalid' on retry and then, as it only specifically checks for 'token invalid' to retry it just stops and returns the current response with the error. And as getdevicelog() does not do any error checking at all and just checks for has_next to loop further, it stops and returns whatever part of the full log it has. |
Hum... It may be good to change the failure logic to raise an exception then have the script start over. If that fixes it, it isn't some odd Tuya API rate limit issue, but something wrong with the token renewal logic. I haven't been able to replicate it but I'm likely not running it long enough. if not self.token:
log.debug("Failed to renew token")
raise ValueError("Failed to renew token") I may have time to look at it this weekend. |
It happens randomly to me and so far I have not been able to find any system to it. I thought it might be because I was requesting too many fetches in too little time. Added time.sleep(1) between fetches, the errors did not go away. Then I thought it might be because I was requesting token renewals too often (every 10 minutes). I started storing the token in a file and passing the old token to Cloud(). Now the script doesn't request a token on every run but still have the errors now and then. |
Originally posted by @ndlarge in #452
The text was updated successfully, but these errors were encountered: