Port 8123 stops listening after a while

Hi,

I’m struggling to find a solution to my problem where my Home Assistant running on a Pi4 works perfectly well after reboot, but after 3d-2w or so, it completely stops responding to api requests. The automation still works perfectly well, but the web interface is completely dead and the app stops working. SSH’ing into the device; netstat -l suggests that the device is NOT listening to port 8123. Restarting core assistant does fix the issue, but it’s super annoying that it does this consistently after some time. Looking at the logs, I do see some network errors, but I’m not convinced they’re responsible for this:

> 2021-03-27 00:24:00 ERROR (MainThread) [pyatv.support.mdns] fail to send to <pyatv.support.mdns.ReceiveDelegate object at 0xa297f9b8>
> Traceback (most recent call last):
>   File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 1048, in sendto
>     self._sock.sendto(data, addr)
> AttributeError: 'NoneType' object has no attribute 'sendto'
> During handling of the above exception, another exception occurred:
> Traceback (most recent call last):
>   File "/usr/local/lib/python3.8/site-packages/pyatv/support/mdns.py", line 328, in _sendto
>     receiver.sendto(message, target)
>   File "/usr/local/lib/python3.8/site-packages/pyatv/support/mdns.py", line 217, in sendto
>     self.transport.sendto(message, target)
>   File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 1058, in sendto
>     self._fatal_error(
>   File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 705, in _fatal_error
>     self._loop.call_exception_handler({
> AttributeError: 'NoneType' object has no attribute 'call_exception_handler'
> 2021-03-27 00:24:01 ERROR (MainThread) [pyatv.support.mdns] fail to send to <pyatv.support.mdns.ReceiveDelegate object at 0xa297fb50>
> Traceback (most recent call last):
>   File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 1048, in sendto
>     self._sock.sendto(data, addr)
> AttributeError: 'NoneType' object has no attribute 'sendto'
> During handling of the above exception, another exception occurred:
> Traceback (most recent call last):
>   File "/usr/local/lib/python3.8/site-packages/pyatv/support/mdns.py", line 328, in _sendto
>     receiver.sendto(message, target)
>   File "/usr/local/lib/python3.8/site-packages/pyatv/support/mdns.py", line 217, in sendto
>     self.transport.sendto(message, target)
>   File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 1058, in sendto
>     self._fatal_error(
>   File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 705, in _fatal_error
>     self._loop.call_exception_handler({
> AttributeError: 'NoneType' object has no attribute 'call_exception_handler'
> 2021-03-27 00:24:01 ERROR (MainThread) [pyatv.support.mdns] fail to send to <pyatv.support.mdns.ReceiveDelegate object at 0xa297f9b8>
> Traceback (most recent call last):
>   File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 1048, in sendto
>     self._sock.sendto(data, addr)
> AttributeError: 'NoneType' object has no attribute 'sendto'
> During handling of the above exception, another exception occurred:
> Traceback (most recent call last):
>   File "/usr/local/lib/python3.8/site-packages/pyatv/support/mdns.py", line 328, in _sendto
>     receiver.sendto(message, target)
>   File "/usr/local/lib/python3.8/site-packages/pyatv/support/mdns.py", line 217, in sendto
>     self.transport.sendto(message, target)
>   File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 1058, in sendto
>     self._fatal_error(
>   File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 705, in _fatal_error
>     self._loop.call_exception_handler({
> AttributeError: 'NoneType' object has no attribute 'call_exception_handler'
> 2021-03-27 00:24:02 ERROR (MainThread) [pyatv.support.mdns] fail to send to <pyatv.support.mdns.ReceiveDelegate object at 0xa297fb50>
> Traceback (most recent call last):
>   File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 1048, in sendto
>     self._sock.sendto(data, addr)
> AttributeError: 'NoneType' object has no attribute 'sendto'
> During handling of the above exception, another exception occurred:
> Traceback (most recent call last):
>   File "/usr/local/lib/python3.8/site-packages/pyatv/support/mdns.py", line 328, in _sendto
>     receiver.sendto(message, target)
>   File "/usr/local/lib/python3.8/site-packages/pyatv/support/mdns.py", line 217, in sendto
>     self.transport.sendto(message, target)
>   File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 1058, in sendto
>     self._fatal_error(
>   File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 705, in _fatal_error
>     self._loop.call_exception_handler({
> AttributeError: 'NoneType' object has no attribute 'call_exception_handler'
> 2021-03-27 00:24:02 ERROR (MainThread) [pyatv.support.mdns] fail to send to <pyatv.support.mdns.ReceiveDelegate object at 0xa297f9b8>
> Traceback (most recent call last):
>   File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 1048, in sendto
>     self._sock.sendto(data, addr)
> AttributeError: 'NoneType' object has no attribute 'sendto'
> During handling of the above exception, another exception occurred:
> Traceback (most recent call last):
>   File "/usr/local/lib/python3.8/site-packages/pyatv/support/mdns.py", line 328, in _sendto
>     receiver.sendto(message, target)
>   File "/usr/local/lib/python3.8/site-packages/pyatv/support/mdns.py", line 217, in sendto
>     self.transport.sendto(message, target)
>   File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 1058, in sendto
>     self._fatal_error(
>   File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 705, in _fatal_error
>     self._loop.call_exception_handler({
> AttributeError: 'NoneType' object has no attribute 'call_exception_handler'

BTW: I’m running Hass OS and I had to enable ssh just to get access to the device after it gets messed up like this.

Versions?

Any custom components?

> hassos: "5.12"
> homeassistant: 2021.3.4
> hostname: homeassistant
> logging: info
> machine: raspberrypi4
> operating_system: Home Assistant OS 5.12

I am currently running:

  • Duck DNS
  • File editor
  • Mosquitto broker
  • Terminal & SSH
  • WireGuard
  • Zigbee2mqtt

HACS

  • Alexa Media Player
  • Scheduler component
  • Emporia Vue Integration

I can try to disable some and figure out which if any is causing the issues.

Actually. Something else is weird here. I restarted core (that makes it work again) and I still can’t see port 8123 as listening when I use netstat -l. I’m a bit confused. Is this caused by the docker containers hidding information from each other?