Javascript PubNub订阅失败

时间:2016-12-23 21:10:49

标签: javascript pubnub

我收到订阅频道组的错误。无法弄清楚原因。这是代码:

var pubnub = new PubNub({
        subscribeKey: subKey,
        publishKey: pubKey
      });

pubnub.addListener({
        status: function(s){
          console.log('status',s);
        },
        message: function(m) {
          var msg = m.message; // The Payload
          console.log('new message',msg);
        },
      });

pubnub.subscribe({
        channelGroups: [viewFinderChannelGroup],
        withPresence: false
      });

结果是:     获取http://ps4.pubnub.com/v2/subscribe/ ... db1b& uuid =& pnsdk = PubNub-JS-Web%2F4.3.3 400(错误)

控制台输出没有多大帮助:

status Object {error: true, operation: "PNSubscribeOperation", statusCode: 400, errorData: Error: Error
at Request.<anonymous> (https://cdn.pubnub.com/sdk/javascript/pubnub.4.3.3.js:1330:…, category: "PNBadRequestCategory"}

1 个答案:

答案 0 :(得分:0)

withPresence不会出错。只需删除wihPresence,它应该是好的。请尝试以下代码。

var pubnub = new PubNub({
        subscribeKey: subKey,
        publishKey: pubKey
      });

pubnub.addListener({
        status: function(s){
          console.log('status',s);
        },
        message: function(m) {
          var msg = m.message; // The Payload
          console.log('new message',msg);
        },
      });

pubnub.subscribe({
        channelGroups: [viewFinderChannelGroup]
      });