home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.5k stars 30.33k forks source link

Unifi connection errors. Repetitious "/v2/api/site/default/trafficrules: Server disconnected" and related #126920

Open TheQue42 opened 2 weeks ago

TheQue42 commented 2 weeks ago

The problem

Every five or ten minutes, I will get 2024-09-27 14:39:02.368 WARNING (MainThread) [homeassistant.components.unifi] Exception on update Error requesting data from https://vimes.disc-world.se:8443/v2/api/site/default/trafficrules: Server disconnected

and less often:

2024-09-27 14:36:09.429 WARNING (MainThread) [homeassistant.components.unifi] Exception on update Error requesting data from https://vimes.disc-world.se:8443/v2/api/site/default/trafficrules: Cannot connect to host vimes.disc-world.se:8443 ssl:False [Connect call failed ('10.9.24.22', 8443)]

So far I have not noticed any issues with the actual functionality of the integration (apart from my eternal issue that clients that move out-of-range of wifi are not detected until very late).

The unifi container is running on the same system (goofball222/unifi:latest-ubuntu), and logs during another debugging timespan, only shows. (most cases nothing useful is shown, at least not on default level). I have also recreated the unifi container, with a backup.

[2024-09-27T13:36:29,591+02:00] <webapi-2> INFO  state  - Added WS listener for site[5b103a81e0acbd2180792952], total count: 3
[2024-09-27T13:38:22,581+02:00] <webapi-8> INFO  state  - Removed WS listener for site[5b103a81e0acbd2180792952], total count: 2
[2024-09-27T13:38:43,464+02:00] <webapi-2> WARN  api    - websocket session error:Connection reset
[2024-09-27T13:38:43,464+02:00] <webapi-2> INFO  state  - Removed WS listener for site[5b103a81e0acbd2180792953], total count: 1
[2024-09-27T13:38:43,465+02:00] <webapi-2> INFO  state  - Removed WS listener for site[5b103a81e0acbd2180792953], total count: 1
[2024-09-27T14:16:20,866+02:00] <fetch-ui-db> INFO  productinfo - [UIDB] Fetching latest UiDb

I have seen: [2024-09-27T15:11:16,560+02:00] <ws-notify-1> WARN api - unable to send over websocket java.lang.IllegalStateException: The remote endpoint was in state [TEXT_FULL_WRITING] which is an invalid state for called method

In the unifi logs but the timestamps don't match with the related log-complaints in homeassistant at least.

Running with the debugging show that the integration is performing GET on https://vimes.disc-world.se:8443/v2/api/site/default/trafficrules every ~TEN seconds, which seems a bit unnecessary since there are none, and never will be.

What version of Home Assistant Core has the issue?

2024.9.3

What was the last working version of Home Assistant Core?

unknown, but i've seen it before, the past months I think.

What type of installation are you running?

Home Assistant OS

Integration causing the issue

unifi

Link to integration documentation on our website

https://www.home-assistant.io/integrations/unifi

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2024-09-27 10:03:22.924 ERROR (MainThread) [aiounifi.interfaces.connectivity] UniFi websocket error: ''
2024-09-27 10:03:22.926 ERROR (MainThread) [homeassistant.components.unifi] Websocket disconnected
2024-09-27 10:06:55.150 WARNING (MainThread) [homeassistant.components.unifi] Exception on update Error requesting data from https://vimes.disc-world.se:8443/v2/api/site/default/trafficrules: Server disconnected
2024-09-27 10:12:14.924 ERROR (MainThread) [aiounifi.interfaces.connectivity] UniFi websocket error: ''
2024-09-27 10:12:14.924 ERROR (MainThread) [homeassistant.components.unifi] Websocket disconnected
2024-09-27 10:12:20.092 WARNING (MainThread) [homeassistant.components.unifi] Exception on update Error requesting data from https://vimes.disc-world.se:8443/v2/api/site/default/trafficrules: Server disconnected
2024-09-27 10:15:15.736 INFO (SyncWorker_5) [homeassistant.components.python_script] Executing set_entity_state.py: {'entity_id': 'sensor.nimly_doorlock_last_unlock_source', 'state': 'IdleSourceState'}
2024-09-27 10:17:39.924 ERROR (MainThread) [aiounifi.interfaces.connectivity] UniFi websocket error: ''
2024-09-27 10:17:39.924 ERROR (MainThread) [homeassistant.components.unifi] Websocket disconnected
2024-09-27 10:30:31.138 DEBUG (MainThread) [aiounifi.interfaces.connectivity] sending (to https://vimes.disc-world.se:8443/v2/api/site/default/trafficrules) get, None, True
2024-09-27 10:30:44.214 DEBUG (MainThread) [aiounifi.interfaces.connectivity] Websocket '{"meta":{"rc":"ok","message":"sta:sync"},"data":[{"site_id":"5b103a81e0acbd2180792953","assoc_time":1726242879,"latest_assoc_time":1726242948,"oui":"Synology Incorporated","user_id":"66b78ce0449a55717d54ab8c","last_ip":"10.9.24.28","last_uplink_name":"PoeSwitch2 Office","first_seen":1723305184,"last_seen":1727425844,"is_guest":false,"disconnect_timestamp":1725742047,"is_wired":true,"usergroup_id":"","last_uplink_mac":"e0:63:da:5c:ec:8c","last_connection_network_name":"Default","mac":"00:11:32:47:24:bf","last_connection_network_id":"5b103a82e0acbd218079295d","hostname":"gollum","_id":"66b78ce0449a55717d54ab8c","_uptime_by_usw":1182937,"_last_seen_by_usw":1727425844,"_is_guest_by_usw":false,"ip":"10.9.24.28","sw_mac":"e0:63:da:5c:ec:8c","wired_rate_mbps":1000,"sw_depth":3,"network":"Default","network_id":"5b103a82e0acbd218079295d","hostname_source":"usw","satisfaction":90,"anomalies":0,"satisfaction_avg":{"total":536580,"count":5962},"uptime":1182965,"wired-tx_bytes":84746567,"wired-rx_bytes":910015412,"wired-tx_packets":805411,"wired-rx_packets":787179,"wired-tx_bytes-r":947.6851431854607,"wired-rx_bytes-r":74.51087120868486,"sw_port":3},{"site_id":"5b103a81e0acbd2180792953","assoc_time":1727416704,"latest_assoc_time":1727418264,"oui":"ASUSTek COMPUTER INC.","user_id":"643efe0ca7b11b00365cd42c","last_ip":"10.9.24.44","last_uplink_name":"PoeSwitch2 Office","first_seen":1681849868,"last_seen":1727425844,"is_guest":false,"disconnect_timestamp":1727372083,"is_wired":true,"usergroup_id":"","last_uplink_mac":"e0:63:da:5c:ec:8c","last_connection_network_name":"Default","mac":"c8:7f:54:6a:87:35","last_connection_network_id":"5b103a82e0acbd218079295d","hostname":"raistlin","_id":"643efe0ca7b11b00365cd42c","_uptime_by_usw":9111,"_last_seen_by_usw":1727425844,"_is_guest_by_usw":false,"ip":"10.9.24.44","sw_mac":"e0:63:da:5c:ec:8c","wired_rate_mbps":1000,"sw_depth":3,"network":"Default","network_id":"5b103a82e0acbd218079295d","hostname_source":"usw","satisfaction":90,"anomalies":0,"satisfaction_avg":{"total":70470,"count":783},"uptime":9140,"wired-tx_bytes":1310934028,"wired-rx_bytes":43873929,"wired-tx_packets":1118188,"wired-rx_packets":317388,"wired-tx_bytes-r":16923.735220296952,"wired-rx_bytes-r":5204.360579394599,"sw_port":2},{"site_id":"5b103a81e0acbd2180792953","ap_mac":"e0:63:da:06:0c:11","assoc_time":1727387894,"latest_assoc_time":1727425781,"oui":"SamsungE","user_id":"5da2efc3cff47e004675a2a0","note":"TQ Sleep Phone","last_ip":"10.9.24.32","last_uplink_name":"ManCave-Ap","first_seen":1570959299,"last_seen":1727425815,"is_guest":false,"disconnect_timestamp":1727329540,"last_radio":"na","is_wired":false,"usergroup_id":"","last_uplink_mac":"e0:63:da:06:0c:11","last_connection_network_name":"Default","mac":"04:d6:aa:1a:73:9b","noted":true,"last_connection_network_id":"5b103a82e0acbd218079295d","hostname":"YodaS8","name":"YodaS8","_id":"5da2efc3cff47e004675a2a0","wlanconf_id":"5b103bb0e0acbd218079296a","_uptime_by_uap":37922,"_last_seen_by_uap":1727425815,"_is_guest_by_uap":false,"ip":"10.9.24.32","channel":36,"radio":"na","radio_name":"wifi1","essid":"TRIPPELSTEG","bssid":"e0:63:da:08:0c:11","powersave_enabled":true,"is_11r":false,"user_group_id_computed":"5b103a82e0acbd218079295e","anomalies":0,"anon_client_id":"34f37c85c37b1523d5bcea1825f852","ccq":1000,"dhcpend_time":1190,"idletime":85,"noise":-105,"nss":2,"rx_rate":270000,"rssi":31,"satisfaction_now":100,"satisfaction_real":100,"satisfaction_reason":0,"signal":-65,"tx_mcs":7,"tx_power":40,"tx_rate":300000,"tx_retry_burst_count":0,"satisfaction":90,"hostname_source":"uap","is_mlo":false,"radio_proto":"ac","channel_width":40,"satisfaction_avg":{"total":271099,"count":2907},"uptime":37921,"tx_bytes":291098167,"rx_bytes":10802544,"tx_packets":233732,"rx_packets":63679,"authorized":true,"qos_policy_applied":true,"bytes-r":0.9178221391811715,"tx_bytes-r":0.0,"rx_bytes-r":0.9178221391811715,"tx_retries":11859,"wifi_tx_attempts":132694,"wifi_tx_dropped":0,"wifi_tx_retries_percentage":0.0,"_uptime_by_usw":2756,"_last_seen_by_usw":1727425844,"_is_guest_by_usw":false,"network":"Default","network_id":"5b103a82e0acbd218079295d"},{"site_id":"5b103a81e0acbd2180792953","assoc_time":1715808096,"latest_assoc_time":1715808150,"oui":"Hangzhou","user_id":"6022f603410df80035f2c73c","last_ip":"172.16.24.66","last_uplink_name":"PoeSwitch2 Office","first_seen":1612903921,"last_seen":1727425844,"is_guest":false,"disconnect_timestamp":1708080839,"is_wired":true,"usergroup_id":"","last_uplink_mac":"e0:63:da:5c:ec:8c","last_connection_network_name":"CamNetwork","mac":"84:9a:40:ad:2e:2c","noted":true,"last_connection_network_id":"5d347ac2c9e77c0046198890","name":"KitchenCam","_id":"6022f603410df80035f2c73c","_uptime_by_usw":12173619,"_last_seen_by_usw":1727425844,"_is_guest_by_usw":false,"ip":"172.16.24.66","sw_mac":"e0:63:da:5c:ec:8c","wired_rate_mbps":100,"sw_depth":3,"network":"CamNetwork","network_id":"5d347ac2c9e77c0046198890","vlan":2424,"satisfaction":90,"anomalies":0,"satisfaction_avg":{"total":536580,"count":5962},"uptime":11617748,"wired-tx_bytes":935037325,"wired-

Additional information

Since my unifi setup doesnt have anything else than switches and wifi APs - and I am assuming that traffic rules are associated with unifi gw's or firewalls - so it would be nice I could disable any firewall rules polling, when it is completely unneeded.

home-assistant[bot] commented 2 weeks ago

Hey there @kane610, mind taking a look at this issue as it has been labeled with an integration (unifi) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `unifi` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign unifi` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


unifi documentation unifi source (message by IssueLinks)

ziolelle commented 1 week ago

Same issue here even with Unifi Protect installed on Unifi Cloud Key G2 Plus on same local network (no firewall rules or routing issues):

Logger: homeassistant.components.unifi
Source: components/unifi/hub/entity_loader.py:94
integration: UniFi Network (documentation, issues)
First occurred: 12:49:59 (1 occurrences)
Last logged: 12:49:59

Exception on update Error requesting data from https://192.168.1.240:443/proxy/network/v2/api/site/default/trafficrules: Cannot connect to host 192.168.1.240:443 ssl:False [Connect call failed ('192.168.1.240', 443)]

Teporary to re-establish it, I need to restart both Unifi Protect and HA Machine

Of course, Unifi Protect is fully working using the Uinfi Interface (via App or web interface)