2

I am working on a project which allows two users on the Internet to have a video call with one other. I am using WebRTC for that.

While doing the research, I came across certain articles. One thing I don't understand in these articles is that why do we even need an 'application server'?

The first link - https://bloggeek.me/webrtc-server/ - In this post, they've explained the different WebRTC servers. I understand that the 'signaling server' is required to connect the two clients, but why do we require an 'application server' to deploy our HTML, CSS and JavaScript files?

Can't we just open the index.html on our browser(without the server) and the script tag in it which refers to the index.js file - handle the signaling server and run on the browser?

Even in this post: https://www.tutorialspoint.com/webrtc/webrtc_architecture.htm - they've mentioned that "Be careful, because WebRTC works only on the server side. If you simply open this page with the browser it won't work. You need to host these files on the Apache or Node servers, or which one you prefer."

Why do we need a server to render our HTML, css, and javascript files? Why can't the video elements be rendered through the connection established through WebRTC APIs and the signaling server running on the browser (in index.js) ?

Adam
  • 21
  • 3
  • the script tag in it which refers to the index.js file - this can work for hello world app, but real apps require to be served from web server, there's a lot of cases besides webrtc that will fail when working locally. – Estus Flask Jun 25 '21 at 23:08

1 Answers1

1

I understand that the 'signaling server' is required to connect the two clients...

Yes, correct.

...but why do we require an 'application server' to deploy our HTML, CSS and JavaScript files? Can't we just open the index.html on our browser(without the server) and the script tag in it which refers to the index.js file - handle the signaling server and run on the browser?

This has to do with secure origins. The browser doesn't inherently trust file: origins. You need to use HTTPS.

Now, this "application server" doesn't have to be anything special. Any static HTTPS hosting is fine. No application needs to run on the server.

Brad
  • 159,648
  • 54
  • 349
  • 530
  • But I have made certain applications like a simple dice game using HTML, CSS, and javascript and opened the index.html on my browser without any problems. Why is there a problem with 'secure origins' here? – Adam Jun 25 '21 at 18:40
  • 1
    @Adam Browser implementers working on Chromium and others have been very aggressive at pushing secure origins with the goal of securing the web. Unfortunately, this means that a lot of newer APIs simply don't work without HTTPS. Browsers have taken on more responsibility for security, despite what the users want, as a way to defend the user. – Brad Jun 25 '21 at 19:17
  • So you mean to say WebRTC APIs are new, hence require HTTPS for security? – Adam Jun 25 '21 at 19:25
  • See also: https://blog.mozilla.org/webrtc/camera-microphone-require-https-in-firefox-68/ – Brad Jun 25 '21 at 20:28
  • Thanks a lot for your help! – Adam Jul 01 '21 at 19:06