question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Retrying subscription on failed auth for private channel

See original GitHub issue

Do you want to request a feature or report a bug? I’m not sure if this is a bug or just incomplete documentation.

What is the current behavior? When I subscribe to a private channel, and the auth server fails for some reason, the channel gets stuck in a weird state that I can’t retry. Trying pusher.subscribe() on the same channel names returns the existing channel object but doesn’t perform an auth request to subscribe to the channel.

**If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar.

var pusher = new Pusher('APP_KEY');
var channel = pusher.subscribe('private-channel');
channel.bind('pusher:subscription_error', function(status) {
  if(status == 408 || status == 503){
    // retry?
  }
});

this is the sample code from the documentation: https://pusher.com/docs/client_api_guide/client_events#subscription_error

but there’s no information on the proper method to retry. calling pusher.subscribe() again doesn’t do anything.

What is the expected behavior? pusher.subscribe() on a channel that failed to auth should subscribe the channel.

As a work around, I dug through the source and found the channel has a method subscribe() that retries the auth process. However, in the code this method was marked as internal use only, so I can’t count on it being there in the future. It does work to retry though. It just looks like the pusher.subscribe() method doesn’t handle the case where a channel is in a failed auth state and retries.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
liamhuberscommented, Dec 21, 2018

There is a little bit of a lack of documentation for this, so this is how I did it:

new Pusher(process.env.PUSHER_KEY, {
  authorizer: (channel) => ({
    authorize: async (socketId, callback) => {
      try {
        // API call which returns an auth token

        callback(null, { auth: response.auth });
      } catch (err) {
        callback(true, err.status);
      }
    },
  }),
});
2reactions
TomKempcommented, Nov 2, 2020

Hi @pesterhazy, I’ve released a new pusher-js version where channels should no longer get stuck in the subscriptionPending state. Let me know if there are any problems.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pusher/Laravel echo error on subscribing to private channel ...
Pusher/Laravel echo error on subscribing to private channel: Auth value for subscription to channel is invalid: should be of format 'key: ...
Read more >
Why Am I Receiving The "Invalid signature: Expected HMAC ...
This error comes from Pusher's server when you're trying to subscribe to a private / presence channel. It happens because of the token......
Read more >
How to interpret and troubleshoot Duo Authentication Proxy ...
KB Guide: A Duo Security Knowledge Base Guide to interpreting and troubleshooting Authentication Proxy debug logs.
Read more >
Troubleshoot Azure Arc-enabled servers agent connection ...
Subscription name was provided, and an error occurred while looking up the corresponding subscription GUID. Retry the command with the ...
Read more >
Teams Troubleshooting & Error Lookup - BitTitan Help Center
These are the steps to enable permission level at the source only. This authentication process gives you control over who is entitled to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found