pusher/pusher-js

Pusher client is not binding correctly on presence channels but on public ones yes

Closed this issue · 2 comments

Do you want to request a feature or report a bug?
Yes

What is the current behavior?
I've built a presence channel called 'presence-{IdChat}', which has user authentication and authorization on the same endpoint ('/api/auth/pusher'). The authentication and authorization of the user is done correctly (at least I have no warnings nor errors and the user data can be retrieved succesfully), and the user is able to subscribe to a channel and send messages. My issue is that when I call channel.bind on the specified channel, the user is able to send messages with the proper structure (as I can see them in the Pusher debug console), but my app does not seem to be fetching this updates to the channel, since I've put a console log inside the channel.bind and it never gets executed. Everytime a user sends a message, a call to an endpoint is called where the following gets executed:

const pusher = new PusherServer({
    appId: process.env.PUSHER_APP_ID,
    key: process.env.NEXT_PUBLIC_PUSHER_KEY,
    secret: process.env.PUSHER_SECRET,
    cluster: 'sa1',
    useTLS: true
  })

  await pusher.trigger(`presence-${IdChat}`, 'chat', {
    id_user: IdUser,
    message
  })

The strange thing is that when I change the channel to be a public channel 'public-{IdChat}' it works as expected. So I do not understand why the presence channel logic is failing if the user is already authorized and authenticated.

What is the expected behavior?
The presence channel should work as the public one when calling channel.bind

Which versions of Pusher, and which browsers / OS are affected by this issue?
Did this work in previous versions of Pusher? If so, which?

I am using Chrome/Windows and the Pusher version is 5.2.0 and my Pusher-js version is 8.4.0-rc2. I am using React as the frontend and Next Js as the backend.

If you need more information I can provide it. Thank you.

Do you see the clients connect and subscribe to the channels correctly in the Pusher Debug Console?

Hi, I saw the pusher: subscribe and found the error. I had an issue with my NextResponse implementation. Thank you anyway for your attention.