-
-
Notifications
You must be signed in to change notification settings - Fork 346
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
Disconnected event not emitted & no reconnect #275
Comments
FWIW, adding a loop:
that was previously there and was removed in e193cae#diff-168726dbe96b3ce427e7fedce31bb0bcL640 makes the plug recover after disconnection. Given that the commit says "remove persistent option" this is a feature and not a bug? (though it seems like a pretty weird decision to me). |
I've found some dead come, namely Line 390 in c3425f9
_sendTimeout triggers.
It also looks to me that |
In earlier versions, if the persistent option was set to false TuyAPI would reconnect to the device on every function call ( You're correct that the line you linked to is dead. Also, I'm not sure why Line 290 in c3425f9
To be honest, it's been a while since I've touched this code but I believe I removed the reconnection code on purpose. It seemed like people were already handling it themselves. I should have documented doing so, at the very least. The new @tuyapi/driver package has a better defined scope, so hopefully that will clear things up a little. Finally, I'm not an expert on Node.js memory management but I think it's fine if |
I would be happy to switch to the typescript @tuyapi/driver but it doesn't seem to provide the service discovery that the old API provides: it requires ip.
If I were to write a fix would you prefer me to fix this library or the typescript driver? |
Fine, I actually figured it out in @tuyapi/driver: _handleSocketConnect calls _recursiveHeartbeat which checks for old heartbeats (this is good and an improvement over how it works here) but the last heartbeat is actually old because it wasn't reset after reconnect. I'll fix that and send a pull request. |
Cool, thanks. (Any fixes baring major bugs should go to the new package). If you look at the development branch of that repo there's a Find class. Not sure yet if I'm going to integrate that with the Device class or leave that up to the consumer, as the driver package is supposed to be lower-level and leave much of the implementation up to the user. You may also want to follow this issue: #169. |
Describe the bug
Disconnected event is not emitted when I remove power from the device. It's only emitted once the device is plugged back in and connects to the network. What's more, the device never recovers.
I think there used to be something called persistent connection with previous versions of TuyAPI. I've recently updated the package and it's not there anymore. So maybe I'm just not using it correctly now?
To Reproduce
Expected behavior
Debug Output
Screenshots
None
Desktop (please complete the following information):
Additional context
None
The text was updated successfully, but these errors were encountered: