freifunkMUC / unifi_respondd

GNU General Public License v3.0
12 stars 8 forks source link

unifi_respondd failed spontaneously #36

Open herbetom opened 2 years ago

herbetom commented 2 years ago

I just encountered the following error with unifi_respondd. I haven't done any research. I only want to post this somewhere.

Feb 23 02:59:05 unifi python[1022]: 2022-02-23 02:59:05,854,854 INFO     [respondd_client.py:328] Using unicast method
Feb 23 02:59:05 unifi python[1022]: 2022-02-23 02:59:05,854,854 DEBUG    [respondd_client.py:332] will now sleep 48 seconds
Feb 23 02:59:53 unifi python[1022]: 2022-02-23 02:59:53,934,934 DEBUG    [controller.py:112] Controller for https://unifi.ffrn.de:443/
Feb 23 02:59:53 unifi python[1022]: 2022-02-23 02:59:53,934,934 DEBUG    [controller.py:181] login() as unifi_respondd
Feb 23 03:00:00 unifi python[1022]: Traceback (most recent call last):
Feb 23 03:00:00 unifi python[1022]:   File "/opt/unifi_respondd/venv/lib/python3.9/site-packages/pyunifi/controller.py", line 31, in wrapper
Feb 23 03:00:00 unifi python[1022]:     return func(*args, **kwargs)
Feb 23 03:00:00 unifi python[1022]:   File "/opt/unifi_respondd/venv/lib/python3.9/site-packages/pyunifi/controller.py", line 139, in _read
Feb 23 03:00:00 unifi python[1022]:     return self._jsondec(response.text)
Feb 23 03:00:00 unifi python[1022]:   File "/opt/unifi_respondd/venv/lib/python3.9/site-packages/pyunifi/controller.py", line 117, in _jsondec
Feb 23 03:00:00 unifi python[1022]:     obj = json.loads(data)
Feb 23 03:00:00 unifi python[1022]:   File "/usr/lib/python3.9/json/__init__.py", line 346, in loads
Feb 23 03:00:00 unifi python[1022]:     return _default_decoder.decode(s)
Feb 23 03:00:00 unifi python[1022]:   File "/usr/lib/python3.9/json/decoder.py", line 337, in decode
Feb 23 03:00:00 unifi python[1022]:     obj, end = self.raw_decode(s, idx=_w(s, 0).end())
Feb 23 03:00:00 unifi python[1022]:   File "/usr/lib/python3.9/json/decoder.py", line 355, in raw_decode
Feb 23 03:00:00 unifi python[1022]:     raise JSONDecodeError("Expecting value", s, err.value) from None
Feb 23 03:00:00 unifi python[1022]: json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Feb 23 03:00:00 unifi python[1022]: During handling of the above exception, another exception occurred:
Feb 23 03:00:00 unifi python[1022]: Traceback (most recent call last):
Feb 23 03:00:00 unifi python[1022]:   File "/opt/unifi_respondd/respondd.py", line 14, in <module>
Feb 23 03:00:00 unifi python[1022]:     main()
Feb 23 03:00:00 unifi python[1022]:   File "/opt/unifi_respondd/respondd.py", line 10, in main
Feb 23 03:00:00 unifi python[1022]:     extResponddClient.start()
Feb 23 03:00:00 unifi python[1022]:   File "/opt/unifi_respondd/unifi_respondd/respondd_client.py", line 359, in start
Feb 23 03:00:00 unifi python[1022]:     self._aps = unifi_client.get_infos()
Feb 23 03:00:00 unifi python[1022]:   File "/opt/unifi_respondd/unifi_respondd/unifi_client.py", line 140, in get_infos
Feb 23 03:00:00 unifi python[1022]:     c.switch_site(site["desc"])
Feb 23 03:00:00 unifi python[1022]:   File "/opt/unifi_respondd/venv/lib/python3.9/site-packages/pyunifi/controller.py", line 218, in switch_site
Feb 23 03:00:00 unifi python[1022]:     for site in self.get_sites():
Feb 23 03:00:00 unifi python[1022]:   File "/opt/unifi_respondd/venv/lib/python3.9/site-packages/pyunifi/controller.py", line 293, in get_sites
Feb 23 03:00:00 unifi python[1022]:     return self._read(self.url + "api/self/sites")
Feb 23 03:00:00 unifi python[1022]:   File "/opt/unifi_respondd/venv/lib/python3.9/site-packages/pyunifi/controller.py", line 38, in wrapper
Feb 23 03:00:00 unifi python[1022]:     raise APIError(err)
Feb 23 03:00:00 unifi python[1022]: pyunifi.controller.APIError: Expecting value: line 1 column 1 (char 0)
Feb 23 03:00:00 unifi systemd[1]: unifi_respondd.service: Main process exited, code=exited, status=1/FAILURE
Feb 23 03:00:00 unifi systemd[1]: unifi_respondd.service: Failed with result 'exit-code'.
Feb 23 03:00:00 unifi systemd[1]: unifi_respondd.service: Consumed 39min 50.074s CPU time.
GoliathLabs commented 2 years ago

The same thing happened to us just yesterday. It seems that sometimes the API returns garbage or errors. This should be dealt with in the code so that it doesn't crash like every time Ubiquiti tampers with the API.

GoliathLabs commented 2 years ago

This also happens sometimes when the system is restarted. @peterbaumert do you have any idea how to handle these API errors?