question

darius-damalakas1695 avatar image
darius-damalakas1695 asked ·

Subscribing to presence events of multiple extensions for multiple RC accounts

Hi,

We are facing a dillema regarding scalability for our backend service. The backend service will be registered as a public app with RC.

The scenario is that our clients can become RC clients. If they do, they will also want to integrate our sass solution Intelligent office (IO) with RingCentral. The goal of the integration is to show all the call logs in IO. In addition to that, we will download call recordings and store them in our servers for later user. 

RC clients (our customers) will enter admin user details into our system, so that our backend job could run in the background and receive call notifications. We are subscribing to presence events for multiple extensions using admin user credentials for each tenant/ RC customer. As I understand, RC internally uses PubNub to deliver notifications as soon as they happen by means of HTTP long polling. 

This works all fine in sandbox, where we have just 1 RC account. My question/concern would be how do we ensure that our backend services scale well when we start adding more RC accounts. I don't believe that having more than 20 subscriptions for different RC accounts would work well, as that would mean 20 HTTP Long polling loops just for the PubNub notifications.

What would be the best strategy here to divide the load, or ensure this scales well. I do hope we are not the first to do this sort of bacekend processing.

Regards
Darius


topic-default
1 |1000 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.

benjamin-dean avatar image
benjamin-dean answered ·
Hello Darrius,

You're correct, you are not the first person to handle this situation. It sounds like you've been able to properly implement a single subscription for multiple extensions using a single account as we've indicated in this article:  https://devcommunity.ringcentral.com/ringcentraldev/topics/subscribing-to-presence-events-of-multipl... so that is a great start. However our Subscriptions (Push Notification) is able to be configured for server-side push notifications over long-polling. If you're not seeing that happen, please let us know. Since the RingCentral Push Notifications use PubNub (which uses Socket.io), you will only have a single HTTP connection (socket) per operating application access_token connected.

Here are a few things you'll want to do for a multi-tenant application such as you are suggesting to set yourself up for the best possible success:
  1. If you do not already have a RingCentral account, I would recommend your organization signup to become a RingCentral ISV Partner: http://www.ringcentral.com/partner/isvreseller.html

    Submitting the above form initiates an internal RingCentral process for our Partner team to contact your organization to setup your account as an Independent Software Vendor (ISV).

  2. Make sure Application Type is set to "Public", this indicates to RingCentral that you want to distribute your application outside of your organization (such as your case to new RingCentral customers whom you refer to us).

  3. Make sure you have defined a valid OAuth Redirect URI for your application. This URI will be used in the 3-Legged OAuth flow described below. For development purposes you can use http://localhost[:PORT][/path/to/redirect/handler], but if you are not using the loopback you will need to use a URI which communicates over port 443 and has a valid SSL chain.

  4. For a SaaS application such as yours, you will want to utilize our 3-Legged OAuth2 (Authentication Credentials Flow) instead of using the ROPC flow you are currently using (where the customer enters their username/password for your system to fetch a token on their behalf). This is a security recommendation (and may be a requirement one day) for multi-tenant applications, it also has the added benefit of removing the burden of authentication from your application/integration as the user is redirected to RingCentral to authenticate and then sent to the Redirect OAuth URI defined for your particular app in Developer Portal. You can read about the RingCentral OAuth2 implementation here: http://ringcentral.github.io/docs/RingCentral_OAuth-2.0_2015-10-08.pdf and there is a tutorial for using the 3-Legged OAuth2 flow here: http://ringcentral.github.io/tutorial/#login-via-3-legged-oauth
Please let me know if this answers your question, and if it does not, then I am happy to expand anything I might have missed.
Share
1 |1000 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.

darius-damalakas1695 avatar image
darius-damalakas1695 answered ·
Thanks Benjamin for swift reply.

Not sure if that matters, but it seems that socket.io is implemented as an NPM package for Node. Our backend system is C#, so does it still apply that there will be only one socket per access_token connected?

Also, I am perhaps worried on the actual frequency and payload size of the HTTP long polling loop. If there will be 100 RC accounts active (or more), that means there will be 100 requests continuously issued to poll PubNub servers. Not the best way of utilizing network resources . If the payload of those requests increases, that might lead to network congestion.  Just interested to hear an opinion, maybe this is fine as it is.  Any chance you know how often polling is done? i.e. how many requests per minute/hour.


As for the a 3 legged OAuth2 (code flow), since our application is a backend service, we don't want to have a risk of accidentally losing refresh_token. This would mean that we would have to detect this and notify user that they have to re-authenticate.  I understand that from security perspective that is better since we would not get hold of username/password, but as it is background service, there is a chance (albeit small, i agree) that we could fail to timely get a new refresh_token.

Darius
Share
1 |1000 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.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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