node.jsnpmmpd

npm mpd - how to authenticate to mpd server


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?


Solution

  • 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);
        });
    });