hjdhjd / homebridge-unifi-protect

:video_camera: Complete HomeKit integration for all UniFi Protect device types with full support for most features including HomeKit Secure Video, and more. https://homebridge.io
Other
1.39k stars 83 forks source link

Newer Unifi Firmware Rate Limits Logins - API Errors #1010

Closed hanzov69 closed 8 months ago

hanzov69 commented 8 months ago

Is your feature request related to a problem? Please describe: Newer Unifi Firmware has introduced an annoying rate limit on authentications, which this plugin will run in to- I believe this is causing many of the API error issues that others are reporting.

Basically, if a user is seeing the API error / "Unable to connect to Protect controller", it's likely due to this issue. Further details and a UniFi side fix are available here: https://community.ui.com/questions/Unifi-API-Rate-Limited/ba82a718-9418-46b0-8f2f-235bfc647f9b

Describe the solution you'd like: Ideally, ubiqituti wouldn't make opaque changes that potentially break things like this, but that's unreasonable to expect from them (I guess). There may be something that can be done on the homebridge-unifi-protect plugin side to cache sessions or create something with persistence? I don't know, out of my wheelhouse I'm afraid.

Describe alternatives you've considered: None to speak of. To be clear, this isn't an issue with the plugin IMO

Additional context:

Screenshot 2023-10-31 at 23 18 24 Screenshot 2023-10-31 at 23 20 24
poindexter12 commented 8 months ago

caching the API credentials will likely solve this issue for the plugin for those that don't want to edit config settings on the device.

hjdhjd commented 8 months ago

Thanks for the request, but it doesn’t belong here - the unifi-protect API library (a different project and repo of mine) is where it would belong that really manages the communication with the Protect controller…EXCEPT…

I already do all this. 😄

HBUP only asks the unifi-protect API to reauthenticate against the Protect controller when it detects an error with communicating with the API, specifically when tapping into the occasionally flaky livestream API that Protect has. We do not reauthenticate regularly. I’d love to not have to reauthenticate at all, but it seems to be the only way to address some of the flakiness that the API has. I do regularly re-test in my private tree to see if they’ve addressed some of their internal quirkiness because it’s unsavory to have to reauthenticate when it’s not needed. 😄

The HBUP webUI does login to the controller independently…that’s just the way it works.

Thanks for the suggestion, but we already don’t reauthenticate without reason as it is. 😄

@poindexter12 yes, it’s possible…and I may implement a mechanism in the future to optionally allow folks to do so in the API library…but I largely view this as an edge condition at the moment that I don’t see as an issue for HBUP in the near-term.

Appreciate the food for thought and the discussion all around.

github-actions[bot] commented 8 months ago

This issue is locked to prevent necroposting on closed issues. Please create a new issue for related support requests, bug reports, or feature suggestions.