DEV Community

Cover image for Let’s Build a Video Chat App with JavaScript and WebRTC

Let’s Build a Video Chat App with JavaScript and WebRTC

Nil Madhab on January 21, 2021

Part 1 : Understanding WebRTC This is the first tutorial in our WebRTC series. The aim of this series is to explain what WebRTC is and how we can u...
Collapse
 
jdreina7 profile image
Parcival

Awesome! Waiting for the second part.

Collapse
 
briancross profile image
Brian Cross

Very cool. I built a WebRTC video chat app a while ago to learn how it works. It’s pretty awesome. I used Twilio for the STUN / TURN server.

Collapse
 
dainspector profile image
Amir Saeidi

Well done! looking forward for the rest.

Collapse
 
liligrvs profile image
tata

Wondering how to create a video conferencing app?This guide will help you get the video conferencing app development essentials and pick the best tools to build your video call app.

Collapse
 
xgubianas profile image
xgubianas

Hi all !
I've done all steps (also open firewall in cloud server), but when I go to the last step (open browser):
82.223.5.78:8000
I get this error:
Error: Cannot find module 'ejs'
Require stack:

  • /var/www/vhosts/guvavet.com/app.guvavet.com/videochat/node_modules/express/lib/view.js
  • /var/www/vhosts/guvavet.com/app.guvavet.com/videochat/node_modules/express/lib/application.js
  • /var/www/vhosts/guvavet.com/app.guvavet.com/videochat/node_modules/express/lib/express.js
  • /var/www/vhosts/guvavet.com/app.guvavet.com/videochat/node_modules/express/index.js
  • /var/www/vhosts/guvavet.com/app.guvavet.com/videochat/index.js at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15) at Function.Module._load (internal/modules/cjs/loader.js:725:27) at Module.require (internal/modules/cjs/loader.js:952:19) at require (internal/modules/cjs/helpers.js:88:18) at new View (/var/www/vhosts/guvavet.com/app.guvavet.com/videochat/node_modules/express/lib/view.js:81:14) at Function.render (/var/www/vhosts/guvavet.com/app.guvavet.com/videochat/node_modules/express/lib/application.js:570:12) at ServerResponse.render (/var/www/vhosts/guvavet.com/app.guvavet.com/videochat/node_modules/express/lib/response.js:1012:7) at /var/www/vhosts/guvavet.com/app.guvavet.com/videochat/index.js:15:6 at Layer.handle as handle_request at next (/var/www/vhosts/guvavet.com/app.guvavet.com/videochat/node_modules/express/lib/router/route.js:137:13)

Of course, all files are into the folders, and XirSys credentials on the file...
what can I do? Thanks in advance !!

Collapse
 
tarun57 profile image
tarun-57

Simply write this in your terminal in root directory:
npm install ejs
click enter, and try again. This should be working

Collapse
 
sagarkava profile image
Sagar Kava

Build a Video Chat App with JavaScript and WebRTC
At videosdk.live/ you will find everything you need to build. Real-time Communication. It is a one-stop solution for adding voice, and video conferencing into your website and app in only 10 minutes.

Collapse
 
boopalanm profile image
Boopalan-M

I have one doubt. could you please explain. how the offers are created and how this function works.
function handleIceCandidate(event) {
console.log('icecandidate event: ', event);
if (event.candidate) {
sendMessage({
type: 'candidate',
label: event.candidate.sdpMLineIndex,
id: event.candidate.sdpMid,
candidate: event.candidate.candidate
}, room);
} else {
console.log('End of candidates.');
}
}

Thanks in advance

Collapse
 
nilmadhabmondal profile image
Nil Madhab • Edited

You have asked me two things:-

  1. How is the offer created?
    The Offer is created using pc.createOffer(setLocalAndSendMessage, handleCreateOfferError); where pc is an object of RTCPeerConnection .

  2. How handleIceCandidate function works?
    Browser starts creating candidates as soon as we create an object of RTCPeerConnection. To handle these candidates, we must pass a handler function to this RTCPeerConnection Object as follows
    pc.onicecandidate = handleIceCandidate; , where pc is an object of RTCPeerConnection .
    Whenever a candidate is created by the browser, the handleIceCandidate function will be called

Collapse
 
tarun57 profile image
tarun-57

Hello Everyone,
I have followed all the steps exactly and accurately, but when i created another tab and write the same room number there, it still just shows a single video instead of two videos. And after refreshing just once, now im not able to view anything at all. It shows "site cant be reached" no matter how many times i close the tab and try several times.
Please guide me through this. Thanks in advance.

Collapse
 
amar28187 profile image
amar28187

How are the "username" and "credentials" deduced, that are used in the ICEServer code snippet. Where do we get them?

Collapse
 
nilmadhabmondal profile image
Nil Madhab

please make an account in XirSys .

Collapse
 
pierre profile image
Pierre-Henry Soria ✨

Thanks for sharing Nil 😊

Collapse
 
arjunkava profile image
Arjun Kava

One more thing, If you are looking for readymate UI and scale follow this article.
dev.to/videosdk/video-calling-in-j...

Collapse
 
nilmadhabmondal profile image
Nil Madhab