Get Rocket.Chat to do video calls without video servers

Rocket.Chat Meet use peer-to-peer WebRTC solution for video conferencing. In this case media streams will be passed from peer to peer without server taking part in this process.

Sound Interesting. Let’s dive in!

Rocket.Chat application has three method available to allow audio and video calls:

  1. BigBlueButton
  2. Jitsi Meet
  3. Rocket.Chat Meet (written and maintain by Rocket.Chat community)

Jitsi Meet and BigBlueButton are both open source projects with large global communities of their own. They are both server based video conferencing and collaboration solutions that are widely used and work across different network topologies.

Rocket.Chat Meet(in some places named as WebRTC), on the other hand, is an experimental P2P WebRTC implementation that does not require the use of a server. However, it is operational only over very restrictive network topologies with certain browsers and currently has a myriad of problems maintaining any level of usable stability. In Rocket.Chat Meet code, native WebRTC JS functions are used for providing all the functionalities for making video calls possible.

Steps to start video conference by Rocket.Chat Meet:

  1. Go to Administration.

2. Go to WebRTC.

3. WebRTC Configuration Section:

4. Here you can enable the channel where you want the video conferences to be held (like public channel, private channel or direct messages). By default all are disabled. Let’s enable WebRTC for private channels or you can enable any option according to your requirement.

5. Next, I will talk about the configuration setting of STUN/TURN Servers in Rocket.Chat.

Let’s have a short overview of what is STUN/TURN server and what is their role in providing peer to peer video conferencing.

First, the STUN server is NOT the video server.

When streaming WebRTC media to a large group of devices, you need to use a media or video server. Let’s assume that you want to generate a 1mbps video stream using WebRTC and broadcast it live to 100 viewers. Without a media server, the device you use will need to use 100mbps uplink connection, something that is both uncommon and in many ways wasteful in resources. Add to that the challenge of having a device sustain such a load with a large number of open connections, and you can see how this is not a feasible alternative. The solution in such cases is to make use of streaming media server. The broadcaster’s device sends its media stream towards the media server, which in turn takes care of streaming that content to its viewers.

For using peer-to-peer WebRTC solution for video conferencing as in Rocket.Chat Meet, stun/turn server are required.

Let’s go in some more depth for clear understanding.

Why should you require a STUN/TURN Server?

Some users try to connect through different IP networks where Firewalls and NATs (Network Address Translators) could include specific policies that do not allow any kind of RTC (Real-time communications) communications. The ICE (Interactive Connectivity Establishment) protocol is used to find the best connection solution. It defines a systematic way of finding possible communication options between a peer and the WebRTC.

Role of STUN server : The STUN (Session Traversal Utilities for NAT) protocol allows clients to discover their public IP address and the type of NAT they are behind. This is something your machine doesn’t know on its own as this “allocation” happens by the NAT you are behind (and you will almost always be behind a NAT). That information is also dynamic in nature — you can’t really rely on the same answer being received each time.This information is used to establish the media connection.

Role of TURN server : TURN (Traversal Using Relays around NAT) is a protocol that assists in the traversal of network address translators (NAT) or firewalls for webRTC applications. TURN Server allows clients to send and receive data through an intermediary server. The TURN protocol is the extension to STUN. In a few cases, client communication endpoints are stuck behind different types of NATs, or when a symmetric NAT is in use, it may be easier to send media through a relay server and it’s called the TURN server.

From where to get STUN and TURN server :

The Google STUN server is something you can freely use for development purposes, but, as a free service, there is no SLA. If you are deploying a commercial application, you should plan to deploy your own STUN/TURN servers.

TURN is most useful for Web, Mobile and IoT clients on networks masqueraded by symmetric NAT devices. But the TURN server cost is high because of the server utilization and huge bandwidth usage in the case where more client connections are established. You can check the price of some commercial TURN servers here.

I will recommend implementing your own STUN/TURN server, using the Coturn project. Coturn is a free and open-source implementation of a TURN and STUN server for VoIP and WebRTC.

After installing and configuring the Coturn server, one can follow the below steps to create and test their STUN/TURN server.

a. Open or create /etc/turnserver.conf file and paste the following content.

b. Testing TURN/STUN server : Go to the Trickle ICE page and enter your own STUN or TURN server details.

c. Then click Add Server and then “Gather candidates” button. If you have configured everything correctly, you should see “Done” as the final result.

I think by above explanation about STUN/TURN server, one is clear what are these server, their role, and how one can implement his own Stun/Turn server. For more detailed steps of creating and configuring your own Stun/Turn server using Coturn you can follow this article.

Now, coming back to configuration settings of stun/turn server in Rocket.Chat. For adding your STUN and TURN Servers in Rocket.Chat, below format should be followed.

A list of STUN and TURN servers separated by comma. Username, password and port are allowed in the format :

By default Rocket.Chat has provided a list of STUN/TURN Servers as shown in the below image.

6. Hit Save.

7. In this Rocket.Chat webRTC file, do the following change in code in order to start video conferencing.

Current : this.overlayEnabled = new ReactiveVar(false);

Change the overlayEnabled configuration from false to true.

Update : this.overlayEnabled = new ReactiveVar(true);

Great! all configuration needed for setting webRTC is done. You are all set to go for video call with your peers with Rocket.Chat Meet.

8. Now go to any private channel, and click on Members icons. From the list of all members in the group, select the person you want to start the video or audio call.

9. As soon as you select one member from the list, you can see the Start Video Call button below the peer profile image.

10. Once you click on the start video call button. A call dialog box will be appear at peer end as shown in below image.

11. As soon as peer accept the call, Hurray! you will be in a video call with the peer you selected above. Snapshot of video conference in Rocket.Chat:

12. For using Share Screen feature in video call powered by webRTC, you need to install Rocket.Chat Screen Share extension from here.

Working demonstration of Audio and Video call in Rocket.Chat powered by webRTC:

Go try it out!

Follow the above steps, we can easily easily start the video and audio call with our friends— All thanks to Rocket.Chat.



Open source enthusiast and contributor | Contributing @ Rocket.Chat’s | Full Stack Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Deepak Agarwal

Open source enthusiast and contributor | Contributing @ Rocket.Chat’s | Full Stack Developer