Skip to content

Instantly share code, notes, and snippets.

@DanyF-github
Created April 9, 2021 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanyF-github/79a9cf0252cfc67c33e6fa5a271e3250 to your computer and use it in GitHub Desktop.
Save DanyF-github/79a9cf0252cfc67c33e6fa5a271e3250 to your computer and use it in GitHub Desktop.

What is Vonage Video (Formerly OpenTok / TokBox)?

Vonage Video (Formerly TokBox / OpenTok) is an API that allows businesses to build a custom video experience within any mobile, web, or desktop application.

This API supports all video use-cases, such as 1:1 video consultations, group video chat, or large scale broadcasts to thousands of people. You're able to record any session with control over how to compose and securely deliver these files to your chosen method of storage. Analytics allow you to see project-by-project summaries in the dashboards or see session-specific analytics through the Advanced Insights API. The Video API enables you to build on our standard always-on encryption and GDPR-compliance capabilities to offer an extensive range of advanced security, firewall-control, regional isolation and compliance certificate options. There are many more features and services provided within the Vonage Video service. For more information on these, please head over to the landing page.

What is WebRTC?

Web Real-Time Communication (WebRTC) is a free and open-source project that provides web browsers and mobile applications to have real-time communication with APIs. WebRTC allows audio and video communication to function within your web browser by allowing communication to happen directly between peer-to-peer, which removes the requirement to install plugins or download any native applications.

What is Vonage Open Source Conferencing and Recording?

Vonage Open Source Conferencing and Recording is your private web-based video conferencing solution. It is based on the Vonage Video API Platform (formerly OpenTok API) and uses the Vonage Video SDKs and APIs. You can deploy the app on your servers to get your video conferencing app running on WebRTC.

If you wish to test this service out without hosting your own servers, you're welcome to head over to our Demo webpage. This demo page is hosted by a default version of the Open Source Conferencing and Recording package, which can be found on our Github Repository.

How Can I Host My Own Video Conferencing Software?

Prerequisites

Installation

To run this server, you'll need to clone the repository and install all required third-party libraries. In your terminal, run the three commands below:

https://gist.github.com/81a60bc92de123200a202a28048d9844

Minimum Configuration

Once you've installed all of the required dependencies, some configuration is required. The very least you'll need to do is define your API key and secret, which you can obtain from the Vonage Video Dashboard.

To start, you'll need to create a config.json file, and the command below will copy a precompiled config.json file with all empty values for you. So run the command:

https://gist.github.com/7dd0a268b0c9f88d47996520e133c77a

Open this file, and the first few lines will be what you see in the example below:

https://gist.github.com/fe8e1750ad87fc3f5f1305ff597fd447

Be sure to replace <key> and <secret> with your Video API key and the corresponding API secret that you retrieved from the Vonage Video Dashboard.

If you do not wish to keep the credentials within your config.json file, you can use environment variables instead. You can set the environment variables using the commands below, again making sure to replace <key> and <secret> with your values:

https://gist.github.com/c239a0e4c03045c90f552cc523748496

Running the Server

Before you run the RTC server, you'll need to make sure Redis is running, so in your terminal, enter the following command:

https://gist.github.com/24c2a60ba33f5231d4069723a6d5226a

The base command to run the server on localhost with all of the default settings, including the default port (8123), is the following command:

https://gist.github.com/5fb838a45f6c32cfa8df44481b1bf39a

However, there are some other flags you can add to your commands for a more customised setup. You can see a few of these examples below:

https://gist.github.com/00bdb22412e70a6c60be74b1f0976e2b

If you wish to use SSL, the server expects the SSL Certificate to be named serverCert.pem and the SSL private key file named serverKey.pem. You can find a pre-generated self-signed SSL certificate pair in the sampleCerts directory.

The flag -S tells the server it needs to enable the launch of a secure server while the flag -C <dir> along with the directory name tells the server where to find the certificates. To run the server using these certificates, you would enter the following:

https://gist.github.com/cf7af906a60db5025fec5d46b2f00bac

For detailed information on available options, run node server -h.

Additional Configuration Options

There are many other options available for configuration to suit your needs. These options can be set either in your config.json file or as an environment variable. The keys for these options are specified first for each choice in the examples below:

  • appName (config.json) / APP_NAME (environment variable) -- The name of the application displayed in various places throughout the lifecycle of the video call. The default value is "Vonage Video Conferencing".

  • introText (config.json) / INTRO_TEXT (environment variable) -- The text displayed under the application name in the first page which displays the precall widget. The default value is 'Welcome to Video Conferencing'.

  • showTos (config.json) / SHOW_TOS (environment variable) -- Whether the app will display the terms of service dialog box and require the user to agree to the terms before joining a room. The default value is false.

  • meetingsRatePerMinute (config.json) / MEETINGS_RATE_PER_MINUTE (environment variable) -- Determines the maximum amount of new meetings that can be created in a minute. Users will be allowed to join a meeting that already exists. Otherwise a message will appear telling them that the service is not available at the moment. If the value is set to any negative number, rate limiting will be turned off and all meetings will be allowed. If this value is set to 0, all new meetings will be rejected. The default value is -1.

  • minMeetingNameLength (config.json) / MIN_MEETING_NAME_LENGTH (environment variable) -- The minimum length of meeting names created. The default value, 0, indicates that there is no minimum length. (You can set this in the config file using the minMeetingNameLength setting.) The default value is 0.

  • maxUsersPerRoom (config.json) / MAX_USERS_PER_ROOM (environment variable) -- The maximum number of users allowed in a room at the same time. Set this to 0, the default, to allow any number of users. The default value is 0.

  • enableRoomLocking (config.json) / ENABLE_ROOM_LOCKING (environment variable) -- Whether or not to include the Lock Meeting command to users in the options menu. This command allows users to prevent new participants from joining a meeting. The default value is true.

  • autoGenerateRoomName (config.json) / AUTO_GENERATE_ROOM_NAME (environment variable) -- Whether or not to auto-generate the room name on behalf of the user. If this setting is turned on, we will use haikunator to generate room names for new rooms. If turned off, users will be prompted to enter a room/meeting name when they visit the landing page and won't be allowed to move forward until they do so. The default value is true.

  • enableEmoji (config.json) / ENABLE_EMOJI (environment variable) -- Whether or not to enable emoji support in the text chat widget.

Customising the UI

For information on how to customise the Vonage Open Source Conferencing and Recording UI, see CUSTOMIZING-UI.

How Is My Service Running?

There is a health status check endpoint at /server/health. You can load this URL to check whether the app can connect to all required external services. On success, this health check endpoint sends a response with the HTTP status code set to 200 and the JSON similar to the following:

https://gist.github.com/a47d5db5c98d0eef2411f7fa07e3c004

An example of a failing health check will be similar to the following:

https://gist.github.com/b8401feeea9946e8170fd12d7315d697

More Reading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment