For those in the know, if I'm running something on my own that may only at any given moment see in the few hundreds of people using it, what's the best approach in terms of server-side infrastructure to support WebRTC apps? Is there any SaaS offering that has a meaningful product?
A few hundred people should be fine! For fun I made https://github.com/pion/rtsp-bench and was doing 14k people before I saw my first hiccup.
You just need watch CPU Usage and Network attributes (loss, congestion etc...) Getting this right will take a little bit of WebRTC knowledge. Happy to answer any specific questions :)
There are also lots of hosted options as well! Real world WebRTC has a few different parts though, https://bloggeek.me/webrtc-server/ is a good intro I think.
I've been using the Twilio Video product and have been pretty happy with it. They do the orchestration on the server so that you can have all of the users connect via WebRTC. It's very easy to use.
Using Xirsys TURN servers happily (be careful some of their "getting started" examples are wrong). I tried to use Twilio, but failed, they did not recognize my mobile phone number. Even after begging 3 times to become their customer and paying for it, I could not succeed.
I had the same issue with Twilio, they couldn't send anything to my number because of the prefix. After many emails, they finally got it working - then two weeks later it was broken again and I simply gave up.
We have been using Twilio and we're sending them hundreds of dollars a month. I'm about to drop it because of their 2FA requirement. Either they accept customers that know how to manage passwords or they don't. I don't give my phone number to ANYONE any more.
Check out Vonage Video: https://www.vonage.com/communications-apis/video/
Their tech is based on a company they acquired, Tokbox. I used Tokbox’s services for large-scale real-time streaming; but their pricing is friendly for small-scale usage too. Solid service, with all the helpful extras you’ll likely need (recording videos, handling differences in browsers, etc.).
Depends a lot on what kind of app it is. There are orders of magnitude differences in requirements between apps that use data channels for relatively meager amounts of data (eg multiplayer games), or audio, or video, or video with server side realtime per participant transcoding etc.
The term 'WebRTC' is overloaded, it can mean the protocol or the API. These samples only cover in the browser. This repo is also kind of dead https://github.com/webrtc/samples/issues/1350
If you are interested in WebRTC out of the browser there are lots of implementations and servers! I am also working on a book 'WebRTC for the Curious'[0] that tries to explain the protocol and the history behind it.
I am sure there are other issues as well. The WebRTC implementation in Chromium is controlled by Google (they have all the commit bits). If they don't agree with your change it isn't going to land. It's a tough position to be in for other businesses and Open Source projects even.
Do you have more details on the Firefox problem?
I have a WebRTC project that is currently in standby (priorities changed) and one issue that I have not been able to troubleshoot was an inability to send audio from Firefox while it somehow worked on Chrome.
It works fine in Firefox (send and receive) as long as you don't need to play on multiple output devices. Currently you can enable a feature flag, use enumerateDevices() and play audio files on specific devices, but you can't hook up WebRTC streams to the devices.
Alex Chronopoulos: "We keep it off because it does not work for everything. It works when we playback a file but not for webaudio or WebRTC. We want to add those too and we keep it off till then."
Out of curiosity: It seems like the communication protocol that's used is RTP and RTCP. And it seems that these work quite well for video and audio streaming. However what if I want to do real time streaming of a custom binary protocol? Like, say, accelerometer data from a robot or similar.
Would the best bet be to attempt to make the protocol RTP and RTCP conformant or would it be possible to make a custom fork of WebRTC which supports custom protocols at the communication layer?
If you want to build a multiple session (multiple people) connecting to a website with their camera and audio on, would you use WebRTC or WebSocket + getUserMedia ? Why ?
WebRTC is going to be better for most users (IMO). WebRTC provides congestion control so video stays real-time. It works pretty well with very little effort.
One to one video/audio is fine and securely end-to-end encrypted with vanilla WebRTC.
But for group conversation this won't scale because with p2p (mesh network) WebRTC, each client has to encode and decode for all users (which might be too much processing to do for the client).
For that reason many group video conf apps use a centralized router when there are several people.
Privacy then becomes an issue, and all group video conf such as Zoom, Skype, etc. are basically unencrypted (not end-to-end) and they can see & log everything (your face, your voice, chat, files exchanged, etc.) because the centralised router routes non-encrypted streams.
Jitsi is going to be an exception by adding a layer of encryption using insertable streams (https://jitsi.org/blog/e2ee/).
So in summary I'd say :
- for 1-to-1 or a few more people go with normal p2p WebRTC.
- for multiple people session, host your own Jitsi server (or rent one from 8x8 or other providers) & use the jitsi SDK/API to integrate it in your app
WebRTC includes things like NAT traversal, peer-to-peer.
IMO, don't forget to look at things like TokBox (Vonage), Twilio, and Agora. If you're just trying to get an MVP/POX, it's a lot easier to start with someone's API, then dig deeper into the details when you're ready.
WebRTC has some difficult-to-debug corner cases that these and APIs already handle for you. (Today I had to convince the boss to try one of the APIs for an MVP because I hit a bug where Chrome and Edge just stopped listening to the microphone. Thanks to these samples, I learned it wasn't our code.)
If I want to add WebRTC capabilities to an existing server, what's the simplest way of doing that? This is for a game, all I need is an unreliable RTCDataChannel
I’m glad people are using the data channel for games; I always see people say “well we could have better networking but browsers only support TCP sockets” but that is not the case.
The most complicated bit is you will need TURN servers for some symmetric NAT cases; either host your own or use something like https://xirsys.com/
42 comments
[ 5.0 ms ] story [ 122 ms ] threadYou just need watch CPU Usage and Network attributes (loss, congestion etc...) Getting this right will take a little bit of WebRTC knowledge. Happy to answer any specific questions :)
There are also lots of hosted options as well! Real world WebRTC has a few different parts though, https://bloggeek.me/webrtc-server/ is a good intro I think.
https://github.com/meetecho/janus-gateway
We have upwards of 100 simultaneous users on it every day, and at the moment it seems to be 100% reliable.
https://www.mizu-voip.com/Software/WebRTCtoSIP.aspx
It has a nice config wizard and built-in STUN and TURN server.
If you are interested in WebRTC out of the browser there are lots of implementations and servers! I am also working on a book 'WebRTC for the Curious'[0] that tries to explain the protocol and the history behind it.
[0] https://webrtcforthecurious.com/
For other WebRTC implementations check out.
* https://github.com/aiortc/aiortc
* https://github.com/shinyoshiaki/werift-webrtc
* https://github.com/rawrtc/rawrtc
* https://gstreamer.freedesktop.org/documentation/webrtc/index...
There is also https://github.com/node-webrtc/node-webrtc this takes Google's WebRTC implementation (used in Chromium) and throws a node.js API on top of it!
Is this still the case? Would you still hypothetically see better audio performance of something like Discord in a standalone app?
I am sure there are other issues as well. The WebRTC implementation in Chromium is controlled by Google (they have all the commit bits). If they don't agree with your change it isn't going to land. It's a tough position to be in for other businesses and Open Source projects even.
enumerateDevices() should enumerate audio output devices (feature behind pref): https://bugzilla.mozilla.org/show_bug.cgi?id=1152401
Enable by default setSinkId pref: https://bugzilla.mozilla.org/show_bug.cgi?id=1498512
Alex Chronopoulos: "We keep it off because it does not work for everything. It works when we playback a file but not for webaudio or WebRTC. We want to add those too and we keep it off till then."
Or is the WebRTC subset/combination of these standards sufficiently different better described as its own protocol?
One nice thing is that the protocol is less flexible. The clients are expected to support NACK, Congestion Control and some other stuff.
I haven't done SIP stuff in 10 years. I just remember you had lots of variety between who you interacted with. Maybe this has gotten better!
Out of curiosity: It seems like the communication protocol that's used is RTP and RTCP. And it seems that these work quite well for video and audio streaming. However what if I want to do real time streaming of a custom binary protocol? Like, say, accelerometer data from a robot or similar.
Would the best bet be to attempt to make the protocol RTP and RTCP conformant or would it be possible to make a custom fork of WebRTC which supports custom protocols at the communication layer?
Some companies have decided to roll their own, https://webrtchacks.com/zoom-avoids-using-webrtc/ is a cool read.
But for group conversation this won't scale because with p2p (mesh network) WebRTC, each client has to encode and decode for all users (which might be too much processing to do for the client).
For that reason many group video conf apps use a centralized router when there are several people.
Privacy then becomes an issue, and all group video conf such as Zoom, Skype, etc. are basically unencrypted (not end-to-end) and they can see & log everything (your face, your voice, chat, files exchanged, etc.) because the centralised router routes non-encrypted streams.
Jitsi is going to be an exception by adding a layer of encryption using insertable streams (https://jitsi.org/blog/e2ee/).
So in summary I'd say :
- for 1-to-1 or a few more people go with normal p2p WebRTC.
- for multiple people session, host your own Jitsi server (or rent one from 8x8 or other providers) & use the jitsi SDK/API to integrate it in your app
IMO, don't forget to look at things like TokBox (Vonage), Twilio, and Agora. If you're just trying to get an MVP/POX, it's a lot easier to start with someone's API, then dig deeper into the details when you're ready.
WebRTC has some difficult-to-debug corner cases that these and APIs already handle for you. (Today I had to convince the boss to try one of the APIs for an MVP because I hit a bug where Chrome and Edge just stopped listening to the microphone. Thanks to these samples, I learned it wasn't our code.)
I routinely hit it to validate my camera/audio options and confirm the audio is sounding good.
[1] https://github.com/feross/simple-peer
[2] https://github.com/justo-rivera/dibujio-client
Ps. Be sure to use a turn server besides a stun one, that was a big headache to get it working on mobile data
I’m glad people are using the data channel for games; I always see people say “well we could have better networking but browsers only support TCP sockets” but that is not the case.
The most complicated bit is you will need TURN servers for some symmetric NAT cases; either host your own or use something like https://xirsys.com/