P2P Video Chat with JavaScript / WebRTC




Create a simple peer to peer chat app (with audio/video) in the browser using pure JavaScript / WebRTC.

Get the same development setup I used in this video: https://www.youtube.com/watch?v=Ads1A7pn2LI

Code examples from this video: https://github.com/shama/letswritecode/tree/master/p2p-video-chat-webrtc

Original source


46 responses to “P2P Video Chat with JavaScript / WebRTC”

  1. Hi Kyle, could you make a tutorial based on this but having more than 2 peers connecting to each other? I checked simple-peer github repo and found the "full-mesh topology" approach but I haven't figured out how to get it done. Much appreciate if you could make a video demo.

  2. How do i enter the console ? i diwnloaded Node.js and I`m on windows, i do not know what to type, the script is not working tried on localhost with wamp help me please !!!
    Can this be used to make a website like omegle ?

  3. I have copied all the files you uploaded to GitHub, but when I run the App on Chrome and give permissions to the Camera, the only thing showed in the YOUR ID textarea is: {"renegotiate":true}

    Any ideas?

  4. how do we migrate this simple demo to a production ready version?
    the current method appears to create bundle.js on the fly in memory, so it's not possible to use (say) pm2 to run nodejs apps as a service.
    budo appears to only produce a running service on port 9966.

    suggestions?

  5. Seems I found this after methods were deprecated. Still a cool demo.

    encountered these problems near the end when using the video feed.

    https://developer.mozilla.org/en-US/docs/Web/API/Navigator/getUserMedia
    This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it…. etc

    upgrade to
    https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia

    also
    [Deprecation] getUserMedia() no longer works on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS.

  6. I am getting this object while listening for data
    {
    "type": "Buffer",
    "data": [
    119,
    111,
    119
    ]
    }

    I am using vue js and here is what I did

    this.peer.on('data', function (data) {
    console.log(data) // shows correct msg
    self.msg = data // shows some object => the above one
    })

  7. Thanks for posting, in 2018 .getUserMedia() is deprecated and requires a secure source to run properly which budo doesn't provide. Any chance of you posting an updated version of this?

  8. Please anyone help me 🙁 . Server starts ok and the gitbash console looks lke this:
    ——————————————————————————————————————————————————————————————————————————

    $ npm start
    > p2p-video-chat-webrtc@0.1.0 start C:UsersKubaDesktopp2p-video-chat-webrtc
    > budo index.js:bundle.js
    {"time":"2018-09-11T22:47:20.341Z","hostname":"DESKTOP-UEU1JRE","pid":17840,"level":"info","name":"budo","message":"Server running at http://localhost:9966/","type":"connect","url":"http://localhost:9966/"}

    ——————————————————————————————————————————————————————————————————————————

    but when I enter "localhost:9966" in the browser, console throws some errors:

    ——————————————————————————————————————————————————————————————————————————
    {"time":"2018-09-11T22:47:30.670Z","hostname":"DESKTOP-UEU1JRE","pid":17840,"level":"info","name":"budo","url":"/","type":"static"}
    _http_outgoing.js:494
    throw new TypeError('The header content contains invalid characters');
    ^
    TypeError: The header content contains invalid characters
    at validateHeader (_http_outgoing.js:494:11)
    at ServerResponse.setHeader (_http_outgoing.js:498:3)
    at serve (C:UsersKubaDesktopp2p-video-chat-webrtcnode_modulesecstaticlibecstatic.js:204:11)
    at C:UsersKubaDesktopp2p-video-chat-webrtcnode_modulesecstaticlibecstatic.js:134:11
    at FSReqWrap.oncomplete (fs.js:153:5)
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! p2p-video-chat-webrtc@0.1.0 start: `budo index.js:bundle.js`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the p2p-video-chat-webrtc@0.1.0 start script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    npm ERR! A complete log of this run can be found in:
    npm ERR! C:UsersKubaAppDataRoamingnpm-cache_logs2018-09-11T22_47_30_688Z-debug.log
    ——————————————————————————————————————————————————————————————————————————

    Could anyone please tell me what is wrong with this? :C
    I downloaded all the code directly from author's github, then run npm install to get all needed packages.

  9. Okay, sorry to be so sceptical, but is it really this simple to build a voip system? I want to integrate a browser based-voip system to my startup and was looking for solutions. Is it seriously this simple to do? Just in case it is, I will not pay a lot of money for some other company to ship this technology. Thanks in advance!

  10. Thankyou. I was lost into things like websockets, trackers and all that…but this video worked like a charm.

    For people watching: you might have to run the budo server with –live flag or it will give an error.

  11. Unfortunately it was a waste of time, because budo seems to ignore the –ssl flag which makes it completely useless. I saved the time to covert everything to express and used another tutorial. It's always the same shit with none-common software which lifetime ends after one or two years after a last update which crashes everything and nobody fix it. It's a really well done tutorial, but the fundament is shit.

  12. I am seeing this tutorial today and I tried to run the code. I was able to setup the chats successfully. However, Once I made this to include video, I am unable to generate any ID's. As a result, I cant connect to the peer. Moreover, both in firefox and chrome, the video 'on' (red flashing button in chrome) and a camera picture in firefox signal appears, however they shut off after some time What do I do?.

  13. Do we need a server to manage the signals? In the examples provided for both data channel and media streaming does not does seem to rely on an explicit signaling server? Sorry if my question looks silly, but I just started reading about it,
    Thank you

  14. hello sir, i tried all your github code and followed each step of this tutorial.
    but whenever i put "npm start " on my shell it gives me
    Error: Cannot find module 'getusermedia' from 'F:satishwebrtc'

    can you solve this problem.

Leave a Reply