Search code examples
pusherpusher-js

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


I am using Pusher in React native.

Trying to get message from debug console.

Success to get 2 message and after I got this message in console:

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"}}}]

This is my binding:

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

And no messages arrived.


Solution

  • Have you turned on Authorised Connections in your Pusher App settings? When enabled all connections are required to subscribe to a private or presence channel, if this does not happen then the connection is closed. See https://pusher.com/docs/channels/using_channels/authorized-connections for information. You should either turn this setting off, or subscribe to a private or presence channel.