HuJohner / homebridge-appletv

Apache License 2.0
22 stars 7 forks source link

Plugin crashes on pyatv error 'Connect call failed' #10

Open sschuste opened 1 year ago

sschuste commented 1 year ago

Describe The Bug:

While updating the Apple TV, the plugin crashes and Homebridge is restarted. This seems to be less a problem of the ATV update, but rather an insufficient error handling in the plugin. The log is quite unambiguous.

To Reproduce:

Expected behavior:

Logs:

[28/03/2023, 09:23:55] Error: Got pyatv Error: [Errno 113] Connect call failed ('192.168.1.164', 32498)

pyatv Stacktrace:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/pyatv/support/knock.py", line 29, in _async_knock
    asyncio.open_connection(str(address), port), timeout=timeout
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.6/asyncio/streams.py", line 75, in open_connection
    lambda: protocol, host, port, **kwds)
  File "/usr/local/lib/python3.6/asyncio/base_events.py", line 777, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.6/asyncio/base_events.py", line 764, in create_connection
    yield from self.sock_connect(sock, address)
  File "/usr/local/lib/python3.6/asyncio/selector_events.py", line 451, in sock_connect
    return (yield from fut)
  File "/usr/local/lib/python3.6/asyncio/selector_events.py", line 481, in _sock_connect_cb
    raise OSError(err, 'Connect call failed %s' % (address,))
OSError: [Errno 113] Connect call failed ('192.168.1.164', 32498)

    at parseState (/usr/local/lib/node_modules/@hujohner/homebridge-appletv/node_modules/@sebbo2002/node-pyatv/src/lib/tools.ts:261:15)
    at NodePyATVDeviceEvents.applyPushUpdate (/usr/local/lib/node_modules/@hujohner/homebridge-appletv/node_modules/@sebbo2002/node-pyatv/src/lib/device-events.ts:94:40)
    at NodePyATVDeviceEvents.parsePushUpdate (/usr/local/lib/node_modules/@hujohner/homebridge-appletv/node_modules/@sebbo2002/node-pyatv/src/lib/device-events.ts:84:14)
    at /usr/local/lib/node_modules/@hujohner/homebridge-appletv/node_modules/@sebbo2002/node-pyatv/src/lib/device-events.ts:156:36
    at Array.forEach (<anonymous>)
    at Socket.onStdOut (/usr/local/lib/node_modules/@hujohner/homebridge-appletv/node_modules/@sebbo2002/node-pyatv/src/lib/device-events.ts:156:18)
    at Socket.emit (node:events:525:35)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Socket.Readable.push (node:internal/streams/readable:234:10)
[28/03/2023, 09:23:55] Got SIGTERM, shutting down Homebridge...

Plugin Config:

        {
            "devices": [
                {
                    "name": "ATV",
                    "host": "192.168.1.164",
                    "credentials": "bc7ae0be .... 436303335396232",
                    "device_state_sensors": [
                        "idle",
                        "paused",
                        "playing"
                    ]
                }
            ],
            "platform": "AppleTV"
        }

Screenshots:

Environment: