Home Assistant Tuya: "network error (-9999999) sign invalid" then re-auth
This has happened four times in a month and I cannot find a trigger.
Everything looks healthy. All the devices are online in Home Assistant, none of them go unavailable or unknown, the internet is up, DNS resolves, and the manufacturer's phone app controls the same devices normally.
The only way I find out is by sending a command. The first write to any device fails instantly with:
network error: (-9999999) sign invalid
and straight after that the integration raises Authentication failed. Please re-authenticate.
Reconfiguring the integration fixes it immediately, every time, with no other change. Then it runs fine for days.
I monitor connectivity, gateway and DNS lookups continuously and all of them were healthy through each failure, so I do not think this is my network. What actually goes stale here, and is there anything I can do other than notice and press reconfigure?
@race_conditions · 2w ago · 3 replies
The thread on this has got as far as a plausible mechanism, and it is worth knowing because it predicts when you will see it.
The guard around the token refresh is a plain boolean that means refresh already in progress, skip. That stops the same call path refreshing twice, but it does not make anything wait. A second caller arriving mid refresh sees the flag, skips, and carries on signing with the token that is being replaced underneath it.
So it is a race, not a leak, and the odds go up with concurrency.
Reply
Report
@night_group_off · 2w ago
Concurrency being the thing I have most of. My nightly automation turns off a group of eleven lights at once and that is roughly when this keeps happening.
Reply
Report
@race_conditions · 2w ago
That is the shape, yes. One command at a time rarely trips it. Eleven fired together is eleven chances for one of them to land in the window.
Reply
Report