FlyingDiver / Indigo-miniUniFi

Minimalistic UniFi plugin for Indigo
MIT License
0 stars 0 forks source link

UniFi controller 7.3.76 log error #39

Closed jstewart99 closed 1 year ago

jstewart99 commented 1 year ago

Just updated my UniFi controller app to version 7.3.76 and noticed the following line now appears frequently in my log file:

UniFi Controller Login Connection Error: HTTPSConnectionPool(host='localhost', port=8443): Read timed out. (read timeout=5.0)

Oddly, the controller device in Indigo generally still shows Login OK (although sometimes it says Connection Error) and all systems appear normal. Just can't get the log entry to go away...not a big deal obviously but something isn't right. I've tried playing with a few things (trying the IP address rather than localhost (no difference) and checking the SSL box in the configure settings (which causes the connection to NOT work)). I have self-signed mkcert created certificate to deal with UniFi's SSL browser login issues...not sure if that's related to this issue or not.

Here's a more detailed log entry sample. You'll notice it seems to alternate fail/success:

Dec 18, 2022 at 9:40:31 AM miniUniFi Debug getPrefsConfigUiValues: miniUniFi Debug validatePrefsConfigUi: valuesDict = UiValuesDict : (dict) logLevel : 10 (string) sep2 : (string) statusNote : (string) updateFrequency : 60 (string) miniUniFi Debug closedPrefsConfigUi: userCancelled = False, valuesDict= UiValuesDict : (dict) logLevel : 10 (string) sep2 : (string) statusNote : (string) updateFrequency : 60 (string) miniUniFi Debug Unifi Controller: Updating controller miniUniFi Debug Unifi Controller: Unifi Standard controller detected miniUniFi Error UniFi Controller Login Connection Error: HTTPSConnectionPool(host='localhost', port=8443): Read timed out. (read timeout=5.0)

Dec 18, 2022 at 9:41:52 AM miniUniFi Debug Unifi Controller: Updating controller miniUniFi Debug Unifi Controller: Unifi Standard controller detected miniUniFi Debug UniFi Controller Login Response: {"meta":{"rc":"ok"},"data":[]} miniUniFi Debug UniFi Controller Status Response: {"meta":{"rc":"ok","up":true,"server_version":"7.3.76","uuid":"cd73ee0e-0cfd-4c42-8e81-38af2b3b1b3a"},"data":[]} miniUniFi Debug Unifi Controller: UniFi Controller Getting Sites miniUniFi Debug UniFi Controller Sites Response: <Response [200]>

Dec 18, 2022 at 9:42:52 AM miniUniFi Debug Unifi Controller: Updating controller miniUniFi Debug Unifi Controller: Unifi Standard controller detected miniUniFi Error UniFi Controller Login Connection Error: HTTPSConnectionPool(host='localhost', port=8443): Read timed out. (read timeout=5.0)

mrstacey1284 commented 1 year ago

I am experiencing the issues. It seems that whenever the UniFi controller in minimized or not in the foreground the miniUniFi device is unable to log in. Once the Unifi Controller is brought back into the foreground the plugin is able to reconnect.

FlyingDiver commented 1 year ago

Try changing the timeout value on line 225 of plugin.py inside the Plugin wrapper. Maybe set it to 10.0.

FlyingDiver commented 1 year ago

Clearly, something changed to make it slow to respond (sometimes).

mrstacey1284 commented 1 year ago

Adjusted to 10.0, reloaded plugin, and am still getting the same error. UniFi Controller Login Connection Error: HTTPSConnectionPool(host='10.0.0.9', port=8443): Read timed out. (read timeout=10.0)

FlyingDiver commented 1 year ago

@mrstacey1284 Are you seeing this error every time? Or does it succeed sometimes? The log posted by @jstewart99 shows it working at least sometimes.

You might also try reducing the polling frequency, maybe it's trying to rate limit you.

I don't think this is an actual plugin issue. It's the controller just not responding.

mrstacey1284 commented 1 year ago

It's only successful when the controller UI is active. It will succeed for a three polling cycles after the controller UI is minimized or sent to the background. I don't think it's a plug-in issue either. Seems to be that the controller software goes to sleep. However, the controller web interface can still be loaded in a browser on a different device when the polling fails in Indigo.

jstewart99 commented 1 year ago

Thanks for some suggestions finally. I updated line 225 as suggested, reloaded the plugin, and that appears to have solved the problem. Ryan - I don't have the Controller UI/Website active (just to be clear that we're talking about the same thing -- the UniFi controller app is running but it's not the front-most app and I don't have a browser window open to manage the network) and it's staying connected, so the active/background status doesn't seem to be affecting anything on my setup. I have a 60-second polling time so also probably not a rate-limiting issue. Sounds like two different problems, but I think mine appears to have been solved with the longer timeout setting. I'll report back if anything changes.

jstewart99 commented 1 year ago

...and spoke too soon. Another timeout error after about 14 minutes/polls. Confirmed read timeout setting of 10.0 at least. Will try 15, as it reconnected on the next attempt.

FlyingDiver commented 1 year ago

Yeah, but a 15 sec timeout on a 60 second poll rate is not good. I do wonder if the shorter timeout would work with a longer poll period.

Or you could just ignore the errors...

jstewart99 commented 1 year ago

Maybe I don't understand how it works, but doesn't that mean "every 60 seconds we try and connect, we wait 15 seconds or until success, and report status". What's not good about it? I want frequent updates but if it takes 90 seconds occasionally rather than 60 seconds, that's ok by me.

BTW 15 second timeout also failed, so I'm at 30 seconds now, which may be overkill, but it's been connected solid for about 45 minutes now without a problem.

"Ignoring the errors" was my default, but unfortunately it was causing problems with some device statuses and making some triggers not work correctly, so I'm grateful if we've found a solution. Will report any changes of course.

FlyingDiver commented 1 year ago

My thinking is that if there's an issue preventing the controller from responding in a timely fashion, then hitting it that often isn't helping things. But I have not had a chance to research issues with the later controller software that you're both running.

jstewart99 commented 1 year ago

Well it seems to be working, FWIW. I'm not sure the frequency of the polling is at all the problem, so much as it just being mysteriously slow to respond at times. The timeout setting obviously doesn't affect "how often I'm hitting it". (Also just doing a longer poll period didn't fix the issue for me, I had tried that originally). I could try a 120 second poll interval but if it ain't broke, I'm going to leave it (unless you want me to try a few things for testing, of course...happy to help). It is odd that I seem to be the only one (possibly Ryan) with this problem, but maybe not everyone updates controller versions quickly. It was damn-near impossible to revert to the older controller version as it had triggered some firmware updates in my devices (which became a nightmare project to unwind the other day), so I'm sort of stuck at 7.3.76, but again, so far so good with 60 second polling and 30 second timeout. Thanks!

mrstacey1284 commented 1 year ago

I opened a ticket with UniFi support since this seems to be an issue with the responsiveness of their app. I have noticed that the web dashboard is much slower and loading the initial login screen takes a very long time. Sometimes failing and requiring a page reload.

FlyingDiver commented 1 year ago

Yeah, that's basically the same symptoms.

jaknudsen commented 1 year ago

I am experiencing the same error message (intermittently).

FlyingDiver commented 1 year ago

Unable to reproduce.