Pusher : : [{"type":"PusherError","data":{"code":4009,"message":"超时内未授权连接"}}]

yoc*_*yoc 1 pusher pusher-js

我在 React Native 中使用 Pusher。

尝试从调试控制台获取消息。

成功收到 2 条消息,在控制台中收到此消息后:

Pusher :  : [{"type":"PusherError","data":{"code":4009,"message":"Connection not authorized within timeout"}}]

Pusher :  : ["State changed","connected -> disconnected"]

Pusher :  : [{"type":"WebSocketError","error":{"type":"PusherError","data":{"code":4009,"message":"Connection not authorized within timeout"}}}]
Run Code Online (Sandbox Code Playgroud)

这是我的绑定:

channel.bind("Chat", function (data) {
      var newArr = initialMessages.reverse();
      var message = creteNewMessage(JSON.stringify(data));
      newArr.push(message);
      console.log(newArr);
    });
Run Code Online (Sandbox Code Playgroud)

并且没有消息到达。

doy*_*doy 5

您是否在 Pusher 应用程序设置中打开了授权连接?启用后,所有连接都需要订阅专用或在线通道,如果没有发生,则连接将关闭。有关信息,请参阅https://pusher.com/docs/channels/using_channels/authorized-connections 。您应该关闭此设置,或者订阅私人或在线频道。