Unable to subscribe to the channel after granting successfully

This is what I do in PHP:

$pubnub = new Pubnub(array(
  'subscribe_key' => '<SUBSCRIBE_KEY>',
  'publish_key' => '<PUBLISH_KEY>',
  'secret_key' => '<SECRET_KEY>',
  'uuid' => $uuid,
));
$grants = $pubnub->grant(true, true, $channel, $auth_key, 0);

It works. I get a 200 response using the auth key and proper access.

Then I do it in JS:

var pubnub = PUBNUB.init({
  auth_key: settings.auth_key,
  subscribe_key: settings.subscribe_key,
  publish_key: settings.publish_key,
  uuid: settings.uuid,
});

pubnub.subscribe({
  channel: settings.channel,
  // auth_key: settings.auth_key,
  // uuid: settings.uuid,
  presence: function(m) {
    console.log('presence', m);
  },
  message: function(m) {
    console.log('message', m);
  }
});

which is about 10,403 errors per second. I tried to include and exclude a bunch of configuration vars, such as uuidand auth_key, but all I get is a lot of 403.

If I turn on origin: 'pubsub.pubnub.com', the event presencefires once or twice, but then there is still a whole group of 403. If I do not turn on origin, only 403, no events.

here_now()JS execution works fine, but is uuidsempty, and occupancyis 0 :

setInterval(function() {
  pubnub.here_now({channel: settings.channel}, function(rsp) {
    console.log('here_now', rsp);
  });
}, 2000);

PHP grant , JS subscribe?

+4
1

PubNub Presence Access Manager

, Presence Access Manager ( ) PubNub, , -pnpres, ( - SDK, ).

$grants = $pubnub->grant(true, true, 'sports,sports-pnpres', $auth_key, 0);

, .

+1

Source: https://habr.com/ru/post/1617475/


All Articles