0

i am using node.js and the npm module mpd to comunicate to a mpd-server on a different host. my client gets connected to the mpd-server, but i can't send any commands to the server. when trying to send commands, i get a

[4@0] {status} you don't have permission for "status"

the mpd-server is protected with a password. i tried to authenticate with this

mpd_client.on('connect', function(){
    mpd_client.on('ready', function() {
        mpd_client.password = req.session.password;
        mpd_client.sendCommand("status");
    });
});

this does not to work. how can i connect to the mpd-server using a password with this module?

Hinrich
  • 13,485
  • 7
  • 43
  • 66

1 Answers1

1

ok, figured it out myself. turns out there is a command for authenticating with mpd

mpd_client.on('ready', function() {
    console.log('mpd ready');
    mpd_client.sendCommand(cmd("password", [<my_password_string>]), function(err, msg) {
        if (err) throw err;
        console.log(msg);
    });
});
Hinrich
  • 13,485
  • 7
  • 43
  • 66
  • I can't get it working with my MPD server. I get an error stating: "Error: [4@0] {idle} you don't have permission for "idle"". Do you have any idea how to get it working? – Andrei Tătar Apr 21 '15 at 11:32
  • it means you do not have properly authenticated to the mpd server. i switched to [komponist](https://www.npmjs.com/package/komponist), another npm package. i recommend you check that out instead, turned out to be much easier to use for me and with better documentation. alternatively, show some code or maybe open a new issue. i will try to help – Hinrich Apr 22 '15 at 21:52
  • I checked out the code and it seems that the "mpd" library sends idle commands before I get a chance to authenticate. I changed my server settings to allow read for unauthenticated connections. After this, it worked fine. I will also check komponist. Thanks – Andrei Tătar Apr 23 '15 at 05:36