synesthesiam/homeassistant-satellite

ConnectionResetError: Cannot write to closing transport.

Opened this issue · 6 comments

Hello,

the installation under the latest version of Raspberry Pi OS (Raspbian GNU/Linux 12 bookworm) worked smoothly. An installation of the service also worked well. However, the satelite seems to stop responding after some time. With journalctl -u homeassistant-satellite.service -f I see that the log is flooded with the following message:

ConnectionResetError: Cannot write to closing transport.

Is it better to switch to docker?

/python3.11/site-packages/aiohttp/client_ws.py:153> exception=ConnectionResetError('Cannot write to closing transport')>
Oct 17 08:05:39 raspberrypi run[9439]: Traceback (most recent call last):
Oct 17 08:05:39 raspberrypi run[9439]: File "/home/pi/homeassistant-satellite/.venv/lib/python3.11/site-packages/aiohttp/client_ws.py", line 156, in send_bytes
Oct 17 08:05:39 raspberrypi run[9439]: await self._writer.send(data, binary=True, compress=compress)
Oct 17 08:05:39 raspberrypi run[9439]: File "/home/pi/homeassistant-satellite/.venv/lib/python3.11/site-packages/aiohttp/http_websocket.py", line 688, in send
Oct 17 08:05:39 raspberrypi run[9439]: await self._send_frame(message, WSMsgType.BINARY, compress)
Oct 17 08:05:39 raspberrypi run[9439]: File "/home/pi/homeassistant-satellite/.venv/lib/python3.11/site-packages/aiohttp/http_websocket.py", line 601, in _send_frame
Oct 17 08:05:39 raspberrypi run[9439]: raise ConnectionResetError("Cannot write to closing transport")
Oct 17 08:05:39 raspberrypi run[9439]: ConnectionResetError: Cannot write to closing transport
Oct 17 08:05:39 raspberrypi run[9439]: ERROR:asyncio:Task exception was never retrieved
Oct 17 08:05:39 raspberrypi run[9439]: future: <Task finished name='Task-2862522' coro=<ClientWebSocketResponse.send_bytes() done, defined at /home/pi/homeassistant-satellite/.venv/lib

Same problem here and also very annoying that speaker keep making sound and i have to reboot rasperry pi with connected speaker to it otherwise it will keep playing sound

Same issue with docker, happens (f.ex.) after a restart of Home Assistant.

Although a graceful reconnect would certainly be the best solution, even crashing the container would help, since docker can be configured to restart the container in that case, same with f.ex. systemd.

Yes, the satellite does not survive a homeassistant restart and keeps spamming the following error:

ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-22736879' coro=<ClientWebSocketResponse.send_bytes() done, defined at /nix/store/p1i55pqyplhbiy476vac7f5060k85ki0-python3.11-aiohttp-3.8.5/lib/python3.11/site-packages/aiohttp/client_ws.py:153> exception=ConnectionResetError('Cannot write to closing transport')>
Traceback (most recent call last):
  File "/nix/store/p1i55pqyplhbiy476vac7f5060k85ki0-python3.11-aiohttp-3.8.5/lib/python3.11/site-packages/aiohttp/client_ws.py", line 156, in send_bytes
    await self._writer.send(data, binary=True, compress=compress)
  File "/nix/store/p1i55pqyplhbiy476vac7f5060k85ki0-python3.11-aiohttp-3.8.5/lib/python3.11/site-packages/aiohttp/http_websocket.py", line 688, in send
    await self._send_frame(message, WSMsgType.BINARY, compress)
  File "/nix/store/p1i55pqyplhbiy476vac7f5060k85ki0-python3.11-aiohttp-3.8.5/lib/python3.11/site-packages/aiohttp/http_websocket.py", line 601, in _send_frame
    raise ConnectionResetError("Cannot write to closing transport")
ConnectionResetError: Cannot write to closing transport

I don't know maybe it's just me but after home assistant goes online again satelliet keeps giving error and after a while also home assistant voice
assistant crashes and doesn't react anymore even locally with text conversation.

The way to repair is to stop satellite script and restart home assistant

Still investigating it

Restarting the satellite once Home Assistant is back up restores functionality for me.