Mic92 / python-mpd2

Python library which provides a client interface for the Music Player Daemon.
GNU Lesser General Public License v3.0
352 stars 119 forks source link

[Question] mpd.base.CommandError: [4@0] {noidle} you don't have permission for "noidle" #165

Closed Schluggi closed 3 years ago

Schluggi commented 3 years ago

Hi, I know this is probably not the best place for my problem. However, do not know what else I can do. I hope you guys can help me anyway.

As described here, I have a problem with Home Assistant and the mpd integration (which uses python-mpd2).

I am getting this error in my home assistant log.

mpd.base.CommandError: [4@0] {noidle} you don't have permission for "noidle"

As far as I know, the first step of an mpd connection is to connect to the mpd server (with an optional password). If I change the password to something wrong, I get a different error. So the connection and authorization seem to work. Is there another level of authorization? If so, what and how can I change this? And is this a client or a server issue?

Mic92 commented 3 years ago

I am not aware of a second level of authorization. Maybe noidle is sent before the password is sent? @mweinelt The following command can dump if this is the case:

$ tcpdump -i any -n port 6600 -A
mweinelt commented 3 years ago

We don't explicitly send noidle.

    async def _connect(self):
        """Connect to MPD."""
        try:
            await self._client.connect(self.server, self.port)

            if self.password is not None:
                await self._client.password(self.password)
        except mpd.ConnectionError:
            return

https://github.com/home-assistant/core/blob/4ab0151fb1cbefb31def23ba850e197da0a5027f/homeassistant/components/mpd/media_player.py#L118-L126

Mic92 commented 3 years ago

Maybe you can help? @chrysn

chrysn commented 3 years ago

The idle command is implicitly sent with async operation when nothing has happened, and noidle pretty much as a precaution against race conditions.

It didn't occur to me that there could be any situation in which noidle is not accepted (not running MPD with passwords myself).

I can't write a patch right now (caught up in deadlines); if someone wants to have it faster than I get to it, look around when __in_idle is set. Might be a bug (more than just me not thinking of password authentication) somewhere, as the connect code doesn't look like it shoudl take IMMEDIATE_COMMAND_TIMEOUT long to execute, especially as it's only started after the hello has been exchanged.

Schluggi commented 3 years ago

Thanks @chrysn for the explanation.

Strangely enough, the problem has just fixed itself. Therefore this issue can be closed.

Big thanks for the support!

Mic92 commented 3 years ago

Thanks @chrysn for the explanation.

Strangely enough, the problem has just fixed itself. Therefore this issue can be closed.

Big thanks for the support!

Let's keep it open. It sounds like a race condition to me, that just would come back in future.