home-assistant-libs / python-matter-server

Python server to interact with Matter
Apache License 2.0
485 stars 76 forks source link

Error 502: Bad Gateway #848

Open jvmahon opened 2 months ago

jvmahon commented 2 months ago

Update: Fixed. See second message, below.

After a reboot today, I now receive the following "502: Bad Gateway" error from the Matter Server and can no longer access the Web UI for the server image

Add-on: Matter Server Matter WebSocket Server for Home Assistant Matter support.

Add-on version: 6.4.1 You are running the latest version of this add-on. System: Home Assistant OS 12.4 (aarch64 / raspberrypi4-64) Home Assistant Core: 2024.8.1 Home Assistant Supervisor: 2024.08.0

Please, share the above information when looking for help or support in, e.g., GitHub, forums or the Discord chat.

s6-rc: info: service banner successfully started s6-rc: info: service matter-server: starting s6-rc: info: service matter-server successfully started s6-rc: info: service legacy-services: starting [08:33:21] INFO: Starting Matter Server... s6-rc: info: service legacy-services successfully started [08:33:24] INFO: Using 'end0' as primary network interface. [08:33:24] INFO: Successfully send discovery information to Home Assistant. 2024-08-11 08:33:32.883 (MainThread) INFO [matter_server.server.stack] Initializing CHIP/Matter Logging... 2024-08-11 08:33:32.884 (MainThread) INFO [matter_server.server.stack] Initializing CHIP/Matter Controller Stack... [1723379613.531995][126:126] CHIP:CTL: Setting attestation nonce to random value [1723379613.565533][126:126] CHIP:CTL: Setting CSR nonce to random value [1723379613.665275][126:126] CHIP:DL: ChipLinuxStorage::Init: Using KVS config file: /tmp/chip_kvs [1723379613.665662][126:126] CHIP:DL: writing settings to file (/tmp/chip_kvs-okCpiK) [1723379613.665867][126:126] CHIP:DL: renamed tmp file to file (/tmp/chip_kvs) [1723379613.666261][126:126] CHIP:DL: ChipLinuxStorage::Init: Using KVS config file: /data/chip_factory.ini [1723379613.688835][126:126] CHIP:DL: ChipLinuxStorage::Init: Using KVS config file: /data/chip_config.ini [1723379613.690121][126:126] CHIP:DL: ChipLinuxStorage::Init: Using KVS config file: /data/chip_counters.ini [1723379613.695369][126:126] CHIP:DL: writing settings to file (/data/chip_counters.ini-Ya764H) [1723379613.697099][126:126] CHIP:DL: renamed tmp file to file (/data/chip_counters.ini) [1723379613.697163][126:126] CHIP:DL: NVS set: chip-counters/reboot-count = 113 (0x71) [1723379613.697946][126:126] CHIP:DL: Got Ethernet interface: end0 [1723379613.698483][126:126] CHIP:DL: Found the primary Ethernet interface:end0 [1723379613.699039][126:126] CHIP:DL: Got WiFi interface: wlan0 [1723379613.837088][126:126] CHIP:DL: Failed to reset WiFi statistic counts 2024-08-11 08:33:33.838 (MainThread) INFO [chip.storage] Initializing persistent storage from file: /data/chip.json 2024-08-11 08:33:33.839 (MainThread) INFO [chip.storage] Loading configuration from /data/chip.json... 2024-08-11 08:33:34.105 (MainThread) INFO [chip.CertificateAuthority] Loading certificate authorities from storage... 2024-08-11 08:33:34.106 (MainThread) INFO [chip.CertificateAuthority] New CertificateAuthority at index 1 2024-08-11 08:33:34.111 (MainThread) INFO [chip.CertificateAuthority] Loading fabric admins from storage... 2024-08-11 08:33:34.111 (MainThread) INFO [chip.FabricAdmin] New FabricAdmin: FabricId: 0x0000000000000002, VendorId = 0x134B 2024-08-11 08:33:34.112 (MainThread) INFO [matter_server.server.stack] CHIP Controller Stack initialized. 2024-08-11 08:33:34.114 (MainThread) INFO [matter_server.server.server] Starting the Matter Server... 2024-08-11 08:33:34.127 (MainThread) INFO [matter_server.server.helpers.paa_certificates] Skip fetching certificates (already fetched within the last 24h). 2024-08-11 08:33:34.128 (MainThread) INFO [chip.FabricAdmin] Allocating new controller with CaIndex: 1, FabricId: 0x0000000000000002, NodeId: 0x000000000001B669, CatTags: [] 2024-08-11 08:33:34.767 (MainThread) ERROR [matter_server.server] Error doing task: Task exception was never retrieved Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/aiorun.py", line 219, in new_coro await coro File "/usr/local/lib/python3.11/site-packages/matter_server/server/server.py", line 182, in start await self._device_controller.initialize() File "/usr/local/lib/python3.11/site-packages/matter_server/server/device_controller.py", line 172, in initialize await load_local_updates(self._ota_provider_dir) File "/usr/local/lib/python3.11/site-packages/matter_server/server/ota/init.py", line 28, in load_local_updates await asyncio.get_running_loop().run_in_executor( File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/matter_server/server/ota/init.py", line 22, in _load_update update = json.load(f) ^^^^^^^^^^^^ File "/usr/local/lib/python3.11/json/init.py", line 293, in load return loads(fp.read(), ^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/json/init.py", line 346, in loads return _default_decoder.decode(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/json/decoder.py", line 353, in raw_decode obj, end = self.scan_once(s, idx) ^^^^^^^^^^^^^^^^^^^^^^ json.decoder.JSONDecodeError: Expecting ',' delimiter: line 4 column 13 (char 51)

jvmahon commented 2 months ago

I was able to fix this.

It looks like this was due to a "local update" .json file with a .json formatting error placed into /addon_configs/core_matter_server/updates

Consider some some exception catching around the code that loads / parses local update .json files to give a clearer error message. Thanks.

(I think this issue can be closed now, just wanted to be sure the error exception catching point was raised for you to consider).