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

IP banning #2658

Closed rodgers86 closed 1 month ago

rodgers86 commented 2 months ago

What version of Music Assistant has the issue?

2.20b0

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

I’m getting lots of failed logins from My home assistants own internal IP address.

Looks like it’s happening hourly and then after so many attempts it’s banning the IP. This is part of the HTTP config.

However in the logs it seems to be to do with the /media folder which I only just started using with Music assistant.

`Logger: homeassistant.components.http.ban Source: components/http/ban.py:135 integration: HTTP (documentation, issues) First occurred: 00:38:10 (5 occurrences) Last logged: 06:38:10

Login attempt or request with invalid authentication from 192.168.6.27 (192.168.6.27). Requested URL: '/media/local/doorbell-2.mp3?authSig=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJiMGY2MzRiNjRlMDk0MmYyOGRkZTJmYTgyY2EzODU1NCIsInBhdGgiOiIvbWVkaWEvbG9jYWwvZG9vcmJlbGwtMi5tcDMiLCJwYXJhbXMiOltdLCJpYXQiOjE3MjA1MzA0NjksImV4cCI6MTcyMDYxNjg2OX0.4RxQTIFmyPFo2GbbtHXigLKWZndKwlULsb95eZ2HQeU'. (Lavf/60.3.100) `

How to reproduce

Happens in the background.

The mp3 file does work fine in MA when the internal IP is not blocked. But over the period of a few hours. The number of failed logins attempting to access this file is causing it to ban the IP. It then doesn’t work.

I’m not actually attempting to play or access this file that often. Like last night it banned the IP overnight.

I’m running on HAOS on Proxmox.

External access is via cloudflare, but I don’t think that’s the issue here as MA is only accessed locally

Music Providers

Filesystem (localdisk)

Player Providers

Only player provider I use is Sonos. But issue appears to be not when I’m actually playing the file

Full log output

No response

Additional information

No response

What version of Home Assistant Core are your running

2024.7.3

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 2 months ago

Are you running MA as an addon or in docker?

rodgers86 commented 2 months ago

Hello I’m running it as the addon

On Wed, 24 Jul 2024 at 06:28, OzGav @.***> wrote:

Are you running MA as an addon or in docker?

— Reply to this email directly, view it on GitHub https://github.com/music-assistant/hass-music-assistant/issues/2658#issuecomment-2246931175, or unsubscribe https://github.com/notifications/unsubscribe-auth/BAXQQNLZQRXL5GORB6HTM2DZN43OJAVCNFSM6AAAAABLHXRRLWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENBWHEZTCMJXGU . You are receiving this because you authored the thread.Message ID: @.***>

OzGav commented 2 months ago

Is 192.168.6.27 the IP of your HA host? What is calling that doorbell mp3, an automation?

rodgers86 commented 2 months ago

Yes that’s the IP of the HA host.

It’s an automation that’s calling it. But it’s only triggered when a button is pressed.

Whereas the IP banning was happening after a few hours even when the automation hadn’t run for days.

Strangely the IP hasn’t been banned for the last few days though.

The automation does work when triggered and play the mp3 via Music Assistant to my speakers.

On Mon, 29 Jul 2024 at 04:20, OzGav @.***> wrote:

Is 192.168.6.27 the IP of your HA host? What is calling that doorbell mp3, an automation?

— Reply to this email directly, view it on GitHub https://github.com/music-assistant/hass-music-assistant/issues/2658#issuecomment-2254865468, or unsubscribe https://github.com/notifications/unsubscribe-auth/BAXQQNN4IY5QEN3COT4BDPDZOWYGZAVCNFSM6AAAAABLHXRRLWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJUHA3DKNBWHA . You are receiving this because you authored the thread.Message ID: @.***>

OzGav commented 2 months ago

OK then let's leave this for now. If the problem goes away please close this, we can always reopen if it comes back.

ljmellor commented 1 month ago

I can confirm that I'm having the same issue. Running HAOS on a VM inside unraid, MASS is the addon version. I have an apache reverse proxy for SSL from the outside world. All reported failed urls are using the internal IP which is correct. I'm quite well versed in linux/networking so happy to test any suggestions that come my way

OzGav commented 1 month ago

Please update to the latest integration via HACS and the latest server version and advise if this is still an issue

janstadt commented 1 month ago

I also am seeing this issue. Running latest stable version of MASS and HA integration. Seems like the webserver is holding on to the token too long and then during scans (or something, no idea what the webserver does) for recently_played_items it is storing the token in the query param instead of trying to get a new one?

mass logs:

2024-08-13 12:47:58.987 ERROR (MainThread) [music_assistant.webserver] Error handling message: music/recently_played_items: Unable to retrieve info for http://192.168.1.68:8123/media/local/audio/alexa_sound.mp3?authSig=[redacted token]: Server returned 401 Unauthorized (authorization failed)

ha logs:

Logger: homeassistant.components.http.ban
Source: components/http/ban.py:135
integration: HTTP ([documentation](https://www.home-assistant.io/integrations/http), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+http%22))
First occurred: August 14, 2024 at 4:47:29 PM (16 occurrences)
Last logged: 7:58:57 AM

Login attempt or request with invalid authentication from 192.168.1.68 (192.168.1.68). Requested URL: '/media/local/audio/alexa_sound.mp3?authSig=[token-redacted]'. (Lavf/60.3.100)

One other note. I tried clearing the cache in MASS settings but that didnt remove anything in the recently played songs section as i had hoped it would.

OzGav commented 1 month ago

This should be fixed in 2.2.0rc1 please confirm

OzGav commented 1 month ago

This will be closed soon assuming fixed

rodgers86 commented 1 month ago

I’ve had no issues since I posted a few weeks back.

Assume it’s fixed for others also

On Thu, 22 Aug 2024 at 11:58, OzGav @.***> wrote:

This will be closed soon assuming fixed

— Reply to this email directly, view it on GitHub https://github.com/music-assistant/hass-music-assistant/issues/2658#issuecomment-2304377053, or unsubscribe https://github.com/notifications/unsubscribe-auth/BAXQQNLIYF5F5GCB7QSTORTZSW73PAVCNFSM6AAAAABLHXRRLWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBUGM3TOMBVGM . You are receiving this because you authored the thread.Message ID: @.***>