Retrying subscription on failed auth for private channel
See original GitHub issueDo 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:
- Created 6 years ago
- Reactions:4
- Comments:9 (4 by maintainers)
Top GitHub Comments
There is a little bit of a lack of documentation for this, so this is how I did it:
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.