Closed Scotty42 closed 1 year ago
Same here
It seems lika an change in the API / Token refresh. I will check this
Expiration period was 86400s some time ago it changed to 3600. Let me know if I can help in any way
Testing locally to further pinpoint the refresh issue with
let expires = response.data.expiresIn; this.log.info('Token valid for ' + JSON.stringify(expires) + 's'); expireTime = Date.now() + (expires - 500) * 1000;
instead of
expireTime = Date.now() + (response.data.expiresIn - (polltime * 2)) * 1000;
Describe the bug Repeatedly I recently face following situation and error state in the log:
AxiosError: Request failed with status code 401
Still the instace is in green state and claims to be connected. HTTP 401 is thrown while token refresh. As I implemented the API in nodered directly before using this adapter I know this error. It happens when the refresh expire time of 3600ms has passed and while refresh API call to easee cloud the refresh token then has already expired. Only remedy is to get a new token and start refresh cycle from scratch.To Reproduce Not immediatly reproducible but happens after repeatedly after some days.
Expected behavior
- Adapter behavior and state detection wrong. After catching a 401 during token refresh the adapter instance shall be in error state AND re-login not trying to re-use the expired refreh token over and over. That is never gonna work
- expiresIn calculation should be re-thought. I fail to follow the logic
expireTime = Date.now() + (response.data.expiresIn - (polltime * 2)) * 1000;
expiresIn is given in ms. Presently 3600. Polling config does not change anything with that. To be on the safe side one could just set expire time toexpireTime = Date.now() + (response.data.expiresIn)-500
as all values are given in ms. But that's just my proposal.Versions:
- Adapter version: 1.0.8
- JS-Controller version: 4.0.24
- Node version: 20.3.1
- Operating system: Arch
Additional context If I had a dev setup for iobroker adapters yet I'd be happy to provide a PR for testing
Thanks for the hint. I have just once tried to recreate. Basically you are right, just thought with polltime to calculate this is what more dynamic, but is also worth net really.
Have that times changed, looks if that is enough and works. Thank you!
please reopen if error exist
Describe the bug
Repeatedly I recently face following situation and error state in the log:
AxiosError: Request failed with status code 401
Still the instace is in green state and claims to be connected. HTTP 401 is thrown while token refresh. As I implemented the API in nodered directly before using this adapter I know this error. It happens when the refresh expire time of 3600ms has passed and while refresh API call to easee cloud the refresh token then has already expired. Only remedy is to get a new token and start refresh cycle from scratch.To Reproduce
Not immediatly reproducible but happens after repeatedly after some days.
Expected behavior
1) Adapter behavior and state detection wrong. After catching a 401 during token refresh the adapter instance shall be in error state AND re-login not trying to re-use the expired refreh token over and over. That is never gonna work 2) expiresIn calculation should be re-thought. I fail to follow the logic
expireTime = Date.now() + (response.data.expiresIn - (polltime * 2)) * 1000;
expiresIn is given in ms. Presently 3600. Polling config does not change anything with that. To be on the safe side one could just set expire time toexpireTime = Date.now() + (response.data.expiresIn)-500
as all values are given in ms. But that's just my proposal.Versions:
Additional context
If I had a dev setup for iobroker adapters yet I'd be happy to provide a PR for testing