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.48k stars 93 forks source link

Homebridge randomly becomes unable to connect to my unifi protect controller #1004

Closed thehessian closed 1 year ago

thehessian commented 1 year ago

Describe The Problem:

Homebridge randomly becomes unable to connect to my unifi protect controller. This happens randomly usually after 1-2 weeks of working flawlessly. I couldn't find any troubleshooting help around this so any help would be greatly appreciated here.

I've found that frequently when I try to log in myself using the username / password I've allocated for homebridge my login attempts fail with "Too many login attempts" so it seems to me that the plugin might be communicating with the unifi protect controller too frequently and hitting login attempt limits.

Sometimes rebooting homebridge has helped, while other times I've needed to add a new user to unifi protect and point the homebridge plugin to the newly created user.

To Reproduce:

Leave homebridge running for a few weeks

Logs:

[10/24/2023, 8:21:11 PM] [UniFi Protect] 192.168.1.1: API error: Unable to connect to the Protect controller. This is usually temporary and will occur during Protect controller reboots and firmware updates.
[10/24/2023, 8:21:21 PM] [UniFi Protect] 192.168.1.1: API error: Unable to connect to the Protect controller. This is usually temporary and will occur during Protect controller reboots and firmware updates.
[10/24/2023, 8:21:31 PM] [UniFi Protect] 192.168.1.1: API error: Unable to connect to the Protect controller. This is usually temporary and will occur during Protect controller reboots and firmware updates.
[10/24/2023, 8:21:41 PM] [UniFi Protect] 192.168.1.1: API error: Unable to connect to the Protect controller. This is usually temporary and will occur during Protect controller reboots and firmware updates.
[10/24/2023, 8:21:51 PM] [UniFi Protect] 192.168.1.1: API error: Unable to connect to the Protect controller. This is usually temporary and will occur during Protect controller reboots and firmware updates.
[10/24/2023, 8:22:01 PM] [UniFi Protect] 192.168.1.1: API error: Unable to connect to the Protect controller. This is usually temporary and will occur during Protect controller reboots and firmware updates.
[10/24/2023, 8:22:11 PM] [UniFi Protect] 192.168.1.1: API error: Unable to connect to the Protect controller. This is usually temporary and will occur during Protect controller reboots and firmware updates.
[10/24/2023, 8:22:21 PM] [UniFi Protect] 192.168.1.1: API error: Unable to connect to the Protect controller. This is usually temporary and will occur during Protect controller reboots and firmware updates.

Homebridge Configuration:

        {
            "controllers": [
                {
                    "address": "192.168.1.1",
                    "password": "XXXXXX",
                    "username": "Homebridge"
                }
            ],
            "name": "UniFi Protect",
            "platform": "UniFi Protect"
        }

Screenshots:

Screenshot 2023-10-24 at 8 52 31 PM

Environment:

jdocPa commented 1 year ago

I have the same problem. Started about 1 month ago. At first, after having tried restarting my RaspPi (4), restarting Homebridge, etc with no success, I was re-flashing my SD and reinstalling everything. eventually I found that a restart of my Cloud Key (Gen2 +), the connection would re-establish. After 2-3 days, the problem would recur. I've tried all of the troubleshooting tips listed on the GitHub repository, and nothing on my router settings or other settings have changed. For what it's worth, just prior to this issue cropping up on Homebridge, I was using HOOBS with similar issues. I thought it was just a HOOBS issue, so I switched to Homebridge. Unfortunately, the issue persists.

Error codes:

[25/10/2023, 09:38:18] [UniFi Protect] 192.168.151.xxx: API error: Throttling API calls due to errors with the 10 previous attempts. Pausing communication with the Protect controller for 5 minutes. [25/10/2023, 09:43:18] [UniFi Protect] 192.168.151.xxx: API error: Resuming connectivity to the UniFi Protect API after pausing for 5 minutes. [25/10/2023, 09:43:18] [UniFi Protect] 192.168.151.xxx: API error: Unable to connect to the Protect controller. This is usually temporary and will occur during Protect controller reboots and firmware updates. [25/10/2023, 09:43:28] [UniFi Protect] 192.168.151.xxx: API error: Unable to connect to the Protect controller. This is usually temporary and will occur during Protect controller reboots and firmware updates. [25/10/2023, 09:43:38] [UniFi Protect] 192.168.151.xxx: API error: Unable to connect to the Protect controller. This is usually temporary and will occur during Protect controller reboots and firmware updates. [25/10/2023, 09:43:48] [UniFi Protect] 192.168.151.xxx: API error: Unable to connect to the Protect controller. This is usually temporary and will occur during Protect controller reboots and firmware updates. [25/10/2023, 09:43:59] [UniFi Protect] 192.168.151.xxx: API error: Unable to connect to the Protect controller. This is usually temporary and will occur during Protect controller reboots and firmware updates. [25/10/2023, 09:44:09] [UniFi Protect] 192.168.151.xxx: API error: Unable to connect to the Protect controller. This is usually temporary and will occur during Protect controller reboots and firmware updates. [25/10/2023, 09:44:19] [UniFi Protect] 192.168.151.xxx: API error: Unable to connect to the Protect controller. This is usually temporary and will occur during Protect controller reboots and firmware updates. [25/10/2023, 09:44:29] [UniFi Protect] 192.168.151.xxx: API error: Unable to connect to the Protect controller. This is usually temporary and will occur during Protect controller reboots and firmware updates. [25/10/2023, 09:44:39] [UniFi Protect] 192.168.151.xxx: API error: Unable to connect to the Protect controller. This is usually temporary and will occur during Protect controller reboots and firmware updates. [25/10/2023, 09:44:49] [UniFi Protect] 192.168.151.xxx: API error: Unable to connect to the Protect controller. This is usually temporary and will occur during Protect controller reboots and firmware updates. [25/10/2023, 09:44:59] [UniFi Protect] 192.168.151.xxx: API error: Throttling API calls due to errors with the 10 previous attempts. Pausing communication with the Protect controller for 5 minutes.

welauyou commented 1 year ago

Mine stopped working about a week ago. I can verify that the IP and username/pw are correct, however now I can't even login for some reason, but I'm able to login directly to the console with no issues.

hjdhjd commented 1 year ago

Thanks for the report @thehessian. For the rest - one person, one issue. I appreciate the desire to provide additional data points…but this is unmanageable for me, and I would appreciate you all respecting the manner in which I choose to provide support here. If you have an issue, please open a separate report and please don’t add to this support request.

That said: if anyone is running a beta or EA version of Protect or UniFi OS…I provide zero support for those scenarios. I’m aware that there are some issues that folks have in the EA versions…you’re on your own. When Ubiquiti releases a GA/production firmware, HBUP will support it, but not before.

@thehessian I’ve noticed this issue in recent GA Protect firmwares - can you try rebooting the UDMP and seeing if that helps? If you believe it’s an issue in HBUP, can you try prior HBUP releases and see if you notice a change in behavior?

I’ve run into a version of this myself over the past few firmware releases of Protect/UniFiOS…I’m still investigating but welcome the additional data points.

jdocPa commented 1 year ago

Thank you for the response, hjdhjd. I understand you’re busy, and I wasn’t looking for direct support. I was just trying to provide more information in case you could use it. For what it’s worth, I’m not running beta software for any of the relevant pieces. Please let me know if I can provide any other information. Thanks for your work on this!

welauyou commented 1 year ago

@hjdhjd - Is there information related to how the authentication mechanism works with the local login account? Happy to raise a support case also with the Ubiquiti team to see if they've made any changes to that authentication mechanism (wouldn't be surprised).

hjdhjd commented 1 year ago

Thank you for the response, hjdhjd. I understand you’re busy, and I wasn’t looking for direct support. I was just trying to provide more information in case you could use it. For what it’s worth, I’m not running beta software for any of the relevant pieces. Please let me know if I can provide any other information. Thanks for your work on this!

Thanks - but that’s why I ask for separate issues…it’s helpful in the macro sense, but until or unless I know the exact setup you have, I can’t correlate them meaningfully. Everyone’s environment is a little different. But appreciate the data point.

I’ve largely seen this issue on UNVR/UNVRPros and some occasional issues on UDMPs, as an example.

thehessian commented 1 year ago

@hjdhjd sure I'll kick off a reboot of the device and see if that helps.

I'm the meantime is there any more verbose debug logging I can turn on that might help diagnose the issue here / any tips you can give me when I'm in state that might help track down the root cause? Didn't see any docs for how it to do that for the plugin. Given that this is only intermittently reproducible for me there's a large lag time between any attempted fix and feedback on whether that fix worked so I'm happy to provide anything that might help diagnose if you can think of anything.

Most of the time this works great so really appreciate the time you've put in making this plugin!

hjdhjd commented 1 year ago

There isn’t, and there’s really not much need to. I can recreate this issue myself as it is. 😄 As unsatisfying as it is, know the following:

  1. It’s on my radar and I’m aware of the issue.
  2. The issue doesn’t appear to be in HBUP…it’s tied to specific versions in the UniFi OS 3.2.x world…and Ubiquiti seems to be actively working on aspects of this in their beta/EA series (though I would not recommend anyone try it…and if you do and things in HBUP break as they well might, as mentioned before, you are on your own).
  3. Regardless I’m working through some ideas on at least automating a mitigation strategy to deal with the annoyance.
  4. The “fix” I’ve found successful is a combination of:
    • Reboot the Protect controller, which typically helps for a period of time
    • Disable the timeshift buffer in HBUP which reduces how often the API is accessed on the Protect controller, and improves the situation somewhat. I like this option least, personally, because it reduces the effectiveness of HKSV.

Thanks for the report…if you notice any meaningful additional pattern profile, I’m certainly open to it, especially if it’s recreatable.

Best of luck!

github-actions[bot] commented 1 year 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.