mihai-dinculescu / tapo

Unofficial Tapo API Client. Works with TP-Link Tapo smart devices. Tested with light bulbs (L510, L520, L530, L610, L630), light strips (L900, L920, L930), plugs (P100, P105, P110, P115, P300), hubs (H100), switches (S200B) and sensors (KE100, T100, T110, T300, T310, T315).
MIT License
372 stars 37 forks source link

Tapo: SessionTimeout #235

Closed Michal-Szczepaniak closed 1 month ago

Michal-Szczepaniak commented 3 months ago

Hi I'm randomly getting Tapo: SessionTimeout errors when creating p110 object and I don't know how to fix it

mihai-dinculescu commented 3 months ago

What hardware version is the device?

Michal-Szczepaniak commented 2 months ago

Application says 1.0

mihai-dinculescu commented 1 month ago

Sorry for taking so long to reply. Is this still an issue? Does it happen all the time? Are you using the Rust or Python version?

Michal-Szczepaniak commented 1 month ago

I'm using Rust version, compiled as a library for my c++ software (cause i thought rewriting it in c++ is too much work lmao)

It seems to happen only when i'm running two instances of my software so like two softwares asking the light/plug for status at the same time

mihai-dinculescu commented 1 month ago

Interesting. Are there any variables shared between the two, or do they run as individual processes? The SessionTimeout error is a bit misleading. It's more like an invalid session error.

Michal-Szczepaniak commented 1 month ago

Its the same code i just have one running "production" 24/7 and one in development

mihai-dinculescu commented 1 month ago

I was wondering if the two instances share the same memory (e.g. by running in the same process on different threads, with the handlers created from the same API client instance). From your last message, it sounds like they aren't sharing any memory.

Michal-Szczepaniak commented 1 month ago

nope

mihai-dinculescu commented 1 month ago

The good news is that I was able to reproduce the issue by trying to talk with the same P110 device from two different machines. The bad news is that I'm not sure what could be done in the library to avoid this issue. All I can do is to recommend to plan for failure and add retry logic in case you want to support this use case.

Michal-Szczepaniak commented 1 month ago

yeah i think its fair, it could be firmware issue?

mihai-dinculescu commented 4 weeks ago

It's hard to say for certain, but it could be that the device can maintain only one session at a time...

Michal-Szczepaniak commented 4 weeks ago

yeah since probably only one app is supposed to manage it but eh, it doesn't really matter as i have only one app running 99% of the time

anyway thanks for effort :P