Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working presence channel #33

Closed
carloquilala opened this issue Dec 9, 2020 · 2 comments
Closed

Working presence channel #33

carloquilala opened this issue Dec 9, 2020 · 2 comments

Comments

@carloquilala
Copy link

carloquilala commented Dec 9, 2020

Can you provide a working presence channel via codesandbox? I need to get all subscribed members

I can't subscribe to my presence channel using the code provided here

First, I can't subscribe using only this config

  const config = {
    // required config props
    clientKey: "<PUSHER_APP_KEY>",
    cluster: "<PUSHER_APP_CLUSTER>",

    // required for private/presence channels
    // also sends auth headers to trigger endpoint
    authEndpoint: "http://xx.xx.xx.xx/pusher/auth",
    auth: {
      headers: {
        Authorization: "Bearer <AUTH TOKEN>",
      }
    }
  };

I can successfully get a response from http://xx.xx.xx.xx/pusher/auth like so

{"auth":"1afff399e76480e04bfe:0c40bb0f16357b2a2cb85f2fb631ea75ff0df0a7c760b36b76e5839c83d7354as"}

then upon looking on dev console, there are no subscriptions at all and gets this message

{"event":"pusher:connection_established","data":"{\"socket_id\":\"3363.1846347\",\"activity_timeout\":120}"}
{"event":"pusher:error","data":{"code":4009,"message":"Connection not authorized within timeout"}}

UPDATE:
I even added channel_data property in the response but no luck based on the documentation of Pusher

https://pusher.com/docs/channels/server_api/authenticating-users

Authentication of a presence channel is performed in exactly the same way as a private channel but the JSON response must also have a channel_data property containing information that you wish to share about the current user
@carloquilala
Copy link
Author

I managed to make this work, the only problem is the format of the auth response, I forgot to include channel_data property

Thanks to this wonderful library.

@mayteio
Copy link
Owner

mayteio commented Dec 10, 2020

Great to hear! My absolute pleasure, glad people are getting good use out of.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants