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.21k stars 44 forks source link

Apple Music - Unable to view library items - 504 #2378

Closed AlexLamond closed 1 month ago

AlexLamond commented 1 month ago

What version of Music Assistant has the issue?

2.1.0b1

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

No response

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

The problem

After linking Apple Music, and confirming that playback is possible, it is not possible to view items under the browse tab.

Issue persists even after re-linking Apple Music with a new key

How to reproduce

Link Apple Music per the steps provided on the MA website

Go to Browse > Apple Music and then select any folder.

Note the 504 error as listed in the logs:

2024-05-28 10:19:31.382 ERROR (MainThread) [music_assistant.webserver] Error handling message: CommandMessage(message_id=14, command='music/browse', args={'offset': 0, 'limit': 50, 'path': 'apple_music--XcyhGmdi://tracks'})
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/webserver.py", line 351, in _run_handler
    result = await result
             ^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/music.py", line 357, in browse
    prov_items = await prov.browse(path, offset=offset, limit=limit)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/models/music_provider.py", line 316, in browse
    async for item in generator:
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/providers/apple_music/__init__.py", line 201, in get_library_tracks
    for item in await self._get_all_items(endpoint, include="artists,albums,catalog"):
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/providers/apple_music/__init__.py", line 534, in _get_all_items
    result = await self._get_data(endpoint, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/helpers/throttle_retry.py", line 72, in wrapper
    return await func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/providers/apple_music/__init__.py", line 562, in _get_data
    response.raise_for_status()
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1070, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 504, message='Gateway Time-out', url=URL('https://api.music.apple.com/v1/me/library/songs?include=artists,albums,catalog&limit=50&offset=150')

Music Providers

Apple Music

Player Providers

N/A, frontend issue

Full log output

No response

Additional information

No response

What version of Home Assistant Core are your running

2024.5.5

What type of installation are you running?

Home Assistant OS

On what type of hardware are you running?

Alternative

MarvinSchenkel commented 1 month ago

Hm, this seems to be working fine on my setup. Can you elaborate a bit more on your hardware setup? Especially curious if there is anything 'non-default' in your network setup.

AlexLamond commented 1 month ago

HA Green > Unifi Switch > Unifi AP DNS: AdGuardHome running on a Pi, but I've ensured no domains are blocked. And a 504 wouldn't be a domain block anyways

MarvinSchenkel commented 1 month ago

HA Green > Unifi Switch > Unifi AP DNS: AdGuardHome running on a Pi, but I've ensured no domains are blocked. And a 504 wouldn't be a domain block anyways

Could you please disable Adguard and try with a 'default' networking setup and let me know if that still results in 504s?

AlexLamond commented 1 month ago

Even with AdGuard out of the equation, and no internet rules on the Home Assistant Green, I see the same error

MarvinSchenkel commented 1 month ago

Even with AdGuard out of the equation, and no internet rules on the Home Assistant Green, I see the same error

There's no way I can reproduce this. Anything else special about your network? Are you using ipv6, or just v4?

AlexLamond commented 1 month ago

Just IPV4. On a Danish internet connection

MarvinSchenkel commented 1 month ago

I am sorry, but I cannot seem to reproduce this at all. Also discussed this issue internally and we are fairly sure this issue is caused by a networking setting / setup on your side and has nothing to do with MA. If you can provide extensive details about your situation, we are more than happy to help you out. However, we currently do not have enough details to suggest any next steps.

OzGav commented 1 month ago

We will close this for now and can reopen if more information can be provided or additional users report this problem.

P.S. More logging may be added to help you diagnose this.