yoc
yoc

Reputation: 220

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.

Upvotes: 1

Views: 3508

Answers (2)

Romko
Romko

Reputation: 1798

In my case, the POST Authorization endpoint was returning the 201 status code by default, while Pusher expects it to be strictly 200.

Upvotes: 0

doydoy
doydoy

Reputation: 4091

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.

Upvotes: 5

Related Questions