question

Andrew Prokop avatar image
Andrew Prokop asked Andrew Prokop edited

Understanding parameters in createSubscription()

I found this in an example of a PubNub subscription. Can someone tell me how the parameters pollInterval and renewHandicapMs are used:

var subscription = subscriptions.createSubscription({ pollInterval: 10 * 1000, renewHandicapMs: 2 * 60 * 1000 });

Also, is it safe to assume that by using the SDK the subscription will be automatically renewed upon expiration? Thanks!

pubnub
1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image
Phong Vu answered

The params are not necessary as they are set default to those values. I don't know why that line is in the getting started sample code. Maybe it was a mistake when we test with different parameters.

This is the correct way to create a subscription using the JS SDK.

const subscriptions = new Subscriptions({
                  
   sdk: sdk
});


The SDK will handle renewal but you need to pay attention to this known issues

https://github.com/ringcentral/ringcentral-js/tree/master/subscriptions#stale-subscriptions

1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Andrew Prokop avatar image
Andrew Prokop answered
1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Andrew Prokop avatar image
Andrew Prokop answered Andrew Prokop edited

I took a look at the code and there appears to be a misunderstanding. The code you gave me is not the line I was referring to. I am interested in the last line of this snippet:


var rcsdk = new SDK({ server: RINGCENTRAL_SERVER, clientId: RINGCENTRAL_CLIENTID, clientSecret: RINGCENTRAL_CLIENTSECRET });

var platform = rcsdk.platform();

var subscriptions = new Subscriptions({ sdk: rcsdk });

var subscription = subscriptions.createSubscription({ pollInterval: 10 * 1000, renewHandicapMs: 2 * 60 * 1000 });


On more thing, all of a sudden I am not receiving events via PubNub. I get them with a webhook, but with the PubNub code I can create the subscription, but the on notification callback is never invoked. Up until a few minutes ago this code was working fine. Is there a limit on how much I use PubNub?

2 comments
1 |1500 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

You don't need to call the subscription.createSubscription(...), you just need to create with the new Subscriptions({}) and pass the sdk instance. The class constructor takes care of the default values

public constructor({
        sdk,
        PubNub,
        pollInterval = 10 * 1000,
        renewHandicapMs = 2 * 60 * 1000,
    }

I don't know about limit in PubNub but there is a limit of 20 active subscriptions. Should you read the list of subscription to check.

0 Likes 0 ·

Thanks. I will try that. Someone should go back and update the documentation to reflect this.

I have not exceeded my subscription count. I've written my code to clean up old subscriptions so I should never have orphans. I executed Get Subscription List and it comes back with my single PubNub subscription. I will keep digging around, but I am not sure what to look for right now.

0 Likes 0 ·

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys