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

问题描述

我在 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","message":"Connection not authorized within timeout"}}}]

这是我的绑定:

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

没有消息到达。

解决方法

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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...