Building video chat into my personal website using WebRTC, WebSockets, and Go

by deneb150on 5/3/21, 7:19 PMwith 64 comments
by emehrkayon 5/3/21, 10:42 PM

Im doing exactly this, but will use it with a raspberrypi with a 7 inch touch screen as my doorbell. Someone hits the link on the screen, it hits the server, server texts me a link to join the video session and thats it really. I got the core code going (I used a simple tornado [python] implementation as it has web sockets built in)

This is the version of the js code that I got going (I couldn't reason about straight inline scripting, I had to make unnecessary classes. you dont need them) https://gist.github.com/emehrkay/1ea9a87a91e00b27843d9b71a3c...

You also need to tell nginx to serve the wss connection with http 1.1 or the handshakes fail

``` location /websocket/path { proxy_pass http://whateverSiteDotCom; proxy_http_version 1.1; proxy_set_header Connection "upgrade"; proxy_set_header Upgrade $http_upgrade; proxy_set_header Origin ''; } ```

by tschellenbachon 5/3/21, 8:28 PM

I feel like part of the reason why software engineering projects are hard to estimate is this. So you want to add video chat..

- this blogpost: 100 loc - pion (open source): 100k loc? - dolby.io/ agora: I'm guessing >1m loc - zoom.... even more?

by ejb503on 5/3/21, 8:53 PM

Not quite so easy as the blog makes out... didn't see any mention of turn and stun servers, and multi-peer adds layers of complexity...

To stably build a negotiation system you'll probably need an infrastructure of websockets and some kind of nosql db to handle identity and other quirks around negotiation...

Example... how do you handle refresh from a new tab or after the connection has dropped... some kind of device signature is probably needed too!!

(We've just spent a year building this for ecommerce @ https://yown.it)

BIG thumbs up for the interest in WebRTC though enormous potential...

by regularemployeeon 5/3/21, 8:27 PM

I tried this myself too and when I try p2p with 4 people, out of 10 tests about 50% of the time I won't be able to see all 4 people or someone wouldn't be able to see all 4 people.

It was really hard to make p2p work and debugging the ice connections was even harder.

by Naacon 5/3/21, 10:54 PM

...and GCP, and pub/sub/ and...

So a little click baity title. If the backend wasn't distributed the title would be a little more apt.

by neophyt3on 5/3/21, 8:58 PM

no mention of turn servers, also p2p does not scale well since its mesh network... good article, but this wont make it to production alone

by SilurianWenlockon 5/10/21, 10:44 AM

I cant see this video feature on his personal website?

by cblconfederateon 5/3/21, 10:42 PM

i wonder if webrtc was built to be intentionally complex or if a better standard would make adoption easier, perhaps in conjunction with a standard server (like we have httpd for html)

by jqpabc123on 5/3/21, 9:39 PM

Anyone have something similar for screen sharing?

by mfbx9da4on 5/4/21, 12:17 AM

Nice, did you setup a turn server?

by mro_nameon 5/4/21, 8:26 AM

nice and concise, chapeau.