You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I'm working on a custom dashboard for GraphQL subscriptions which are backed by Pusher. My dashboard shows information about the state of the GraphQL system (like query string, variables, query context, etc) and information about the underlying transport system -- Pusher in this case.
To improve this dashboard, I want to be able to count subscribers on a Pusher channel ... but I don't know if the manager of the Pusher app has turned on subscription counting yet.
I thought I would just try -- I could request channel_info(channel, info: "subscription_count"), and if that raises a Pusher::Error, then I would re-fetch withoutinfo: and only display :occupied from the response. But, I found that my second request to channel_info raised the same error (Bad request: Cannot retrieve the subscription count because subscription counting is not enabled), even though it was called without an info: option. I tried info: nil and info: "", but neither of those made it work.
Here's a small replication script of this issue:
require'pusher'# this app doesn't have subscription_count turned on yet:pusher=Pusher::Client.new(app_id: "my-app-id",key: "my-app-key",secret: "my-app-secret",cluster: 'us2',use_tls: true)beginpusher.channel_info("abcdef",info: "subscription_count")rescuePusher::Error=>errputs"Encountered an error: #{err.message.inspect}"endpusher.channel_info("abcdef")
When I run that script, it rescues the first error, but the second .channel_info call raises another error:
$ ruby pusher_test.rb
Encountered an error: "Bad request: Cannot retrieve the subscription count because subscription counting is not enabled"
/Users/rmosolgo/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/pusher-2.0.3/lib/pusher/request.rb:89:in `handle_response': Bad request: Cannot retrieve the subscription count because subscription counting is not enabled (Pusher::Error)
from /Users/rmosolgo/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/pusher-2.0.3/lib/pusher/request.rb:39:in `send_sync'
from /Users/rmosolgo/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/pusher-2.0.3/lib/pusher/resource.rb:9:in `get'
from /Users/rmosolgo/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/pusher-2.0.3/lib/pusher/client.rb:168:in `get'
from /Users/rmosolgo/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/pusher-2.0.3/lib/pusher/client.rb:255:in `channel_info'
from pusher_test.rb:18:in `<main>'
Is there a way to either:
Handle this error such that later .channel_info calls succeed?
Or, detect whether the current app has subscription_count turned on?
Thanks so much for taking a look! Let me know if there's anything else I can do on my side to help with this.
The text was updated successfully, but these errors were encountered:
Hi! I'm working on a custom dashboard for GraphQL subscriptions which are backed by Pusher. My dashboard shows information about the state of the GraphQL system (like query string, variables, query context, etc) and information about the underlying transport system -- Pusher in this case.
To improve this dashboard, I want to be able to count subscribers on a Pusher channel ... but I don't know if the manager of the Pusher app has turned on subscription counting yet.
I thought I would just try -- I could request
channel_info(channel, info: "subscription_count")
, and if that raises aPusher::Error
, then I would re-fetch withoutinfo:
and only display:occupied
from the response. But, I found that my second request tochannel_info
raised the same error (Bad request: Cannot retrieve the subscription count because subscription counting is not enabled
), even though it was called without aninfo:
option. I triedinfo: nil
andinfo: ""
, but neither of those made it work.Here's a small replication script of this issue:
When I run that script, it rescues the first error, but the second
.channel_info
call raises another error:Is there a way to either:
.channel_info
calls succeed?subscription_count
turned on?Thanks so much for taking a look! Let me know if there's anything else I can do on my side to help with this.
The text was updated successfully, but these errors were encountered: