music-assistant / hass-music-assistant

Turn your Home Assistant instance into a jukebox, hassle free streaming of your favorite media to Home Assistant media players.
Apache License 2.0
1.32k stars 49 forks source link

ConnectionResetError: [Errno 104] Connection reset by peer #2552

Closed bruvv closed 3 months ago

bruvv commented 3 months ago

What version of Music Assistant has the issue?

2.0.7

What version of the Home Assistant Integration have you got installed?

2024.6.2

Have you tried everything in the Troubleshooting FAQ and reviewed the Open and Closed Issues and Discussions to resolve this yourself?

The problem

When selecting my 3 chromecast players in a universul group I can see that 3 of them are in the player group in the speaker selector:

image

But when I go to the group settings I see:

image

When selecting the 3rd speaker again I see this error in the server happening. Restart does not help:

2024-06-30 11:32:02.681 INFO (MainThread) [music_assistant.streams] Start Queue Flow stream for Queue Music Assistant Group - crossfade: True
2024-06-30 11:32:21.732 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 1013, in _read_ready__data_received
    data = self._sock.recv(self.max_size)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/helpers/webserver.py", line 136, in _handle_catch_all
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/providers/ugp/__init__.py", line 392, in _serve_ugp_stream
    await resp.write(chunk)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_response.py", line 517, in write
    await self._payload_writer.write(data)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/http_writer.py", line 119, in write
    await self.drain()
  File "/usr/local/lib/python3.12/site-packages/aiohttp/http_writer.py", line 171, in drain
    await self._protocol._drain_helper()
  File "/usr/local/lib/python3.12/site-packages/aiohttp/base_protocol.py", line 95, in _drain_helper
    await asyncio.shield(waiter)
ConnectionError: Connection lost
2024-06-30 11:32:21.796 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 1013, in _read_ready__data_received
    data = self._sock.recv(self.max_size)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/helpers/webserver.py", line 136, in _handle_catch_all
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/providers/ugp/__init__.py", line 392, in _serve_ugp_stream
    await resp.write(chunk)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_response.py", line 517, in write
    await self._payload_writer.write(data)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/http_writer.py", line 119, in write
    await self.drain()
  File "/usr/local/lib/python3.12/site-packages/aiohttp/http_writer.py", line 171, in drain
    await self._protocol._drain_helper()
  File "/usr/local/lib/python3.12/site-packages/aiohttp/base_protocol.py", line 95, in _drain_helper
    await asyncio.shield(waiter)
ConnectionError: Connection lost
2024-06-30 11:32:21.807 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 1013, in _read_ready__data_received
    data = self._sock.recv(self.max_size)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/helpers/webserver.py", line 136, in _handle_catch_all
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/providers/ugp/__init__.py", line 392, in _serve_ugp_stream
    await resp.write(chunk)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_response.py", line 517, in write
    await self._payload_writer.write(data)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/http_writer.py", line 119, in write
    await self.drain()
  File "/usr/local/lib/python3.12/site-packages/aiohttp/http_writer.py", line 171, in drain
    await self._protocol._drain_helper()
  File "/usr/local/lib/python3.12/site-packages/aiohttp/base_protocol.py", line 95, in _drain_helper
    await asyncio.shield(waiter)
ConnectionError: Connection lost
2024-06-30 11:32:22.184 INFO (MainThread) [music_assistant.streams] Start Queue Flow stream for Queue Music Assistant Group - crossfade: True
2024-06-30 11:32:23.113 WARNING (Thread-6) [pychromecast.socket_client] [Bedroom speaker(10.92.69.252):8009] Error communicating with socket, resetting connection

How to reproduce

  1. Add a universal group with at least 3 speakers
  2. Save it and refresh the webserver
  3. See only 2 are added to the group
  4. Add the 3rd again, and error pops up

Music Providers

N.a.

Player Providers

Universal group using chromecast only (HK Citation 200 and JBL music)

Full log output

log.txt

Additional information

No response

What version of Home Assistant Core are your running

2024.6.4

What type of installation are you running?

Home Assistant OS

On what type of hardware are you running?

Generic x86-64 (e.g. Intel NUC)

OzGav commented 3 months ago

You cant use Universlal groups for cast devices. You need to group them in the Google home app.

bruvv commented 3 months ago

Why is that no where mentioned? The weird thing is it works fine. it is just the error in the background.

OzGav commented 3 months ago

Music Assistant supports playing to cast groups which are created in the Google Home app

https://music-assistant.io/player-support/google-cast/

OzGav commented 3 months ago

All devices (except Chromecast) can be grouped but not all will play in sync

https://music-assistant.io/player-support/universal/

bruvv commented 3 months ago

gotcha thanks.

bruvv commented 3 months ago

@OzGav how is it possible I do have a google home group called speakers it is now showing up in the home assistant service?

image

How am I supposed to automate this? I am now using spotcast which does work but it is missing cross fade

OzGav commented 3 months ago

I would check the list of entities in HA SETTINGS>>INTEGRATIONS>>MUSIC ASSISTANT. The group should be seen there. If not check that it is working ok in MA and then maybe try a MA and then HA restart