In this first part of this series on How to Build WebRTC Applications Using CPaaS, we explored why using a CPaaS is helpful when building live video apps. In this second post, we will explore how to use a CPaas. The specific implementation steps will vary depending on the provider (more on that in the third post!), but the overall process is very similar for all of them.
The steps to implement a CPaaS are:
- Create an account with a CPaaS provider
- Provide your billing information
- Interact with the platform
- Monitor your usage
Let’s look at each of these in turn.
Create an Account with a CPaaS Provider
First, you need to create an account with the provider you choose. This will vary depending on each one, but it will usually be a matter of going to its website and searching for a “Register” or “Sign up” button.
After you provide some information about you and your organization, you should be directed to a main dashboard from where you will be able to manage everything related to the services they offer.
Some providers allow “secondary accounts” or “sub-users” to grant your team access to the CPaaS without having to share credentials.
Next, generate a set of API keys or access tokens that you will use to interact with the platform from your application. This set of credentials is the one that you will use to create WebRTC sessions that your users will join.
Make sure you store and exchange these values securely using something like LastPass, 1Password or any private communication channel you prefer. Otherwise, an unauthorized user can take advantage of it and create sessions for its own benefit at your expense… literally! You will be the one paying for it, which leads us to the next step.
Provide Billing Information
We’ve talked before about the reasons for choosing Native, Open Source, or CPaaS to build your WebRTC applications. For good or bad, one of the features of a CPaaS is that you generally pay a monthly fee according to usage. Usage may include how much traffic you are generating, how many users are connected, how many minutes you are using, and whether you are broadcasting or just simply peer-to-peer.
Therefore, you must add your billing information into the newly created account. This will be used to pay for your usage and will grant you access to the provider’s platform. This configuration is usually available under “Settings” or “Configuration” options.
Some providers offer trial periods to test their services without having to enter any credit card info. However, if you don’t enter such information your application, you could end up losing functionality when the period finishes.
Interact With The Platform
Once you have set up your account and have billing information in place, it’s time to start using the platform! Grab the API keys or access tokens you got in the first step and add them to your application.
As a best practice, add these as environment variables in your application backend code. You can use secret vaults or any kind of service for managing secrets such as AWS Secrets Manager.
As mentioned before, you should keep these keys private. Avoid adding them to any kind of client side application or code that is executed at client side, not even as environment variables! Any secret value should only only be added to server side code.
If you need to use such values in the client side, implement a server-level interface such as an authenticated REST API endpoint in your backend. Use this to retrieve any value you need and keep it in-memory only while it’s being used.
Depending on the provider, you might have to add external libraries that will have the required functionality or make direct requests to their REST API or any other interface they provide.
This way you will be able to create the WebRTC sessions and manage all the aspects related to it, such as the codecs that are supported, enable recordings, and any other feature that such a provider offers.
Monitor Your Usage
Once your application is live and you have started to run some WebRTC sessions, you can usually monitor it from the same dashboard where you initially started. Depending on the provider, you should be able to check statistics about your sessions such as the amount of sessions, minutes, location of the participants, and other important metrics that reflect the quality of connections.
Some providers allow you to perform troubleshooting so you can make adjustments to your applications if something goes wrong. This is a very useful feature that is sometimes overlooked when working with CPaaS providers.
Stay tuned for the final in this series:
- How to Build WebRTC Applications Using CPaaS, Part Three: The Options