This JavaScript application demonstrates setting up WebRTC with the Kaazing Gateway and Kaazing JavaScript SDK.
For more information about how to deploy WebRTC with the Kaazing WebSocket Gateway, see Deploy WebRTC using the Gateway.
This demo requires that you have Docker and Docker Compose installed. If this is your first time using Docker, follow the Docker Getting Started Guides:
This demo requires that the host name kaazing.example.com
resolve to the Docker host machine. To enable this resolution, add an entry in your hosts file for kaazing.example.com
that points to your Docker host's IP address. For example, if you are using Docker Machine, you can get the IP address with this command: docker-machine ip
. If you are using Kitematic, go to Settings then Ports. For other examples, see 10 Examples of how to get Docker Container IP Address.
-
Clone or fork this repo.
-
Start the infrastructure by running
docker-compose up --build
-
In one browser tab, navigate to https://kaazing.example.com/demo/. If this is your first time running the demo you will be prompted with a security exception. This exception appears because WebRTC requires clients run on a secure site and the demo certificate is not trusted by your browser. Click through this dialogue (on Chrome click on the Advanced section).
-
Log in with the user bob and password bob.
-
Open a second browser tab at https://kaazing.example.com/demo/ and log in with username alice and password alice.
-
From the alice tab, you can now call bob.
You can setup the same configuration but this time using Enterprise Shield to protect your topology.
-
Stop all docker containers from previous demo
-
Run
docker-compose -f docker-compose-es.yml up --build
-
Clone or fork this repo. The location you cloned this repo to will be referred to as
REPO_HOME
. -
Download and install Kaazing WebSocket Gateway - Enterprise Edition. The location you install the Gateway will be referred to as
GATEWAY_HOME
. -
Copy the contents of
REPO_HOME/gateway/conf
intoGATEWAY_HOME/conf
, being sure to replace any files that already exist. These are the configuration files that will be used by the Gateway. -
Copy the
REPO_HOME/webrtc
folder toGATEWAY_HOME/web
such thatGATEWAY_HOME/web/webrtc
is a valid path. These are the application files that will run in the browser. -
Create a
lib
directory inGATEWAY_HOME/web/webrtc
. -
Next you need the client libraries. Download the JavaScript client libraries. Extract the entire contents and of the zip file and put them in
GATEWAY_HOME/web/webrtc/lib
. -
Download and run a TURN server. If you choose to use coTURN, start it with the following command:
coturn -n -a -v --use-auth-secret --realm=demo --static-auth-secret=kaazshared --rest-api-separator=:
- Edit the
/etc/hosts
file on the machine where the Gateway will run and add the following:
a.b.c.d kaazing.example.com broker
e.f.g.h coturn
Replace a.b.c.d
with the IP address of the Gateway host. The JMS broker will also run on this machine.
Replace e.f.g.h
with the IP address of the machine the TURN server is running on.
- Edit the
/etc/hosts
file on any machines where you will run the WebRTC client application in a browser and add the following:
a.b.c.d kaazing.example.com
Replace a.b.c.d
with the IP address of the Gateway host.
- Start the gateway. Currently WebRTC is an early access feature, so you'll need to see the appropriate access flags first:
turn.rest
andturn.proxy
.
Windows:
% cd GATEWAY_HOME
% set GATEWAY_OPTS=-Dfeature.turn.rest -Dfeature.turn.proxy
% bin/gateway.start --broker jms
(Remember to replace GATEWAY_HOME
with the path where you installed the Gateway.)
Linux
Since the gateway is using port 443, you'll need to use sudo
:
$ cd GATEWAY_HOME
$ sudo GATEWAY_OPTS="-Dfeature.turn.rest -Dfeature.turn.proxy" bin/gateway.start --broker jms
(Remember to replace GATEWAY_HOME
with the path where you installed the Gateway.)
-
In one browser tab, navigate to https://kaazing.example.com/demo/. If this is your first time running the demo, you will be prompted with a security exception. This exception appears because WebRTC requires clients run on a secure site and the demo certificate is not trusted by your browser. Click through this dialogue (on Chrome click on the Advanced section).
-
Log in with the user bob and password bob.
-
Open a second browser tab at https://kaazing.example.com/demo/ and log in with username alice and password alice.
-
From the alice tab, you can now call bob.