MonkeyBonkey
MonkeyBonkey

Reputation: 47901

subscription error in subscribing to a pusher presence channel

I'm trying to go through a basic presence channel example with pusher.js and I'm getting a pusher subscription_error , invalid auth response for channel, expected channel_data field

    var presenceChannel = pusher.subscribe('presence-' + room);

    presenceChannel.bind_all(function(err) {
        console.log("err: " + err);

    });

    presenceChannel.bind('pusher:subscription_succeeded', function(members) {
        members.each(function(member) {
            console.log(member);
        });
    });

Is there some sort of initialization that I need to do to create a presence channel beforehand? Or can I just connect to one and it will create a presence channel. Does subscribing to a presence channel add my presence info to it as a member?

Upvotes: 2

Views: 1967

Answers (1)

MonkeyBonkey
MonkeyBonkey

Reputation: 47901

So it looks like authorization on presence endpoints need to be implemented and have a userinfo parameter passed in which I wasn't doing server side.

var presenceData = {
                    user_id: request.auth.credentials.id,
                    user_info: {
                        uname:  request.auth.credentials.uname
                    }
                };

var auth = pusher.authenticate(socketId, channel, presenceData);

Upvotes: 1

Related Questions