In this post we are going to use the Janus SIP gateway plugin to build a WebRTC to SIP / SIP to WebRTC communication and monitor it with Homer. If you need media server capabilities don’t build things from scratch. You can use one of the most popular Open Source media server such as Jitsi, Kurento or Janus WebRTC gateways. All of them have been tested and are used in, at least, dozens of production environments.

Amongst this popular frameworks we find Janus, a general purpose WebRTC Gateway developed by Meetecho. By adding a variety of plugins, you can achieve different use cases, for example, an SFU. Its implementation is in C language. It is open source, lightweight and it becomes ideal for companies that require a high degree of customization or want to avoid the cost of WebRTC PaaS. For those reasons it has become very popular to the point of being used by big companies such as Slack. If you are curious about their implementation you can find an interesting post here.

Deploying Janus Gateway with the SIP Gateway plugin in a Docker container

Janus Gateway Installation

Although it is possible to install the Janus gateway directly in a linux server, following the official Readme documentation here, in this example we are going to build a docker container with the janus gateway so we can run it seamlessly in any platform.

If you want to test all the plugins you can clone this repository and you will be able to build the janus gateway with all enabled. But usually we won’t need all the plugins. For example, in our use case, we are just going to use the SIP Gateway plugin, so we used the following optimized dockerfile:

Janus Gateway Configuration

Once downloaded, you can change all the configuration. The configured lines are all of those at the end of the dockerfile where RUN sed is used.

If you want to set up a logging/monitoring system such as Homer, you should change the backend url to yours, e.g: public-server-ip:7777. Once you are done with the optional configuration of the file you will have to do:

docker build -t sip-janus-gateway .

And docker will create an image with the Janus gateway with the SIP plugin, its needed dependencies and any specified configuration. After that we can run:

docker run -d -p 7088:7088 -p 7089:7089 -p 8088:8088 -p 8089:8089 -p 8188:8188 -p 8189:8189 -p 10000-10500:10000-10500/udp sip-janus-gateway -S -e

Where we will open the Janus Gateway RESTful API ports 8088-8089, WebSocket API ports 8188-8189    Admin/monitor web server HTTP ports 7088-7089 and the rtp_port_range 10000-10500. Also, we added -S stun_srv_addr to let janus discover its own public IP through the specified STUN. And we added -e to enable event handlers be able to see SIP events.

Gateway testing

After few seconds you should be able to reach the HTTP gateway port at public-server-ip/janus/info:8088. It should show information about the gateway. And if you want to debug any issues you can use the docker logs command.

Adding the frontend

If you decided to use the whole janus gateway demo with all the plugins, you will be able to play around with the different options such as streaming, video-call, SIP gateway, video room or screen sharing. If you used the SIP gateway only dockerfile you will need a frontend, the fastest way will be to just clone the janus SIP gateway demo which can be found here (HTML), here and here (JS) and run them1, for example, with nodejs or in the /var/www/html path of an apache server.


Once all is up and running we will be able to register to any registrar, in this case we will be using linphone. On the other side I will use another linphone client running in an Android phone.  Once both sides are registered we can place the call from any of the clients.  Calling from the front end to a SIP client.

Monitoring Call logs with Homer

Now that we have the gateway running we will start to monitor it. For doing this we will need the event handlers enabled in Janus, hepipe, logging application that will convert the janus events to the needed HEP format and Homer5 which will store and display the logs.



For running hepipe we will need to clone the repository, install the dependencies npm install copy the default janus config.js file in the main directory and run it with node hepipe.js.

Take a look at the configuration file, hepipe will be listening the port 7777 from Janus and passing it to the 9060 of Homer.

We are almost there! Now we just need Homer5. Homer5 is a set of different elements: An apache web app, a Kamailio SIP server and a MySQL DB. In this case again I would suggest docker for building and running it. You can have it running with all the elements in a docker container with a single command:

docker run –restart unless-stopped -tid -p 80:80 -p 9060:9060/udp -v /tmp/homer_mysql_prod/:/var/lib/mysql sipcapture/homer-docker

Where the docker container will have the ports 80 (for the web app) and 9060 (for receiving the logs) open and the MySQL volume will be available in the specified local machine directory. For this to work we need to have hepipe running. When you are registering or calling you should be able to see logs displayed in the console, where you have running hepipe.

Once done we are ready to start monitoring, just login to your server url with the default credentials (username:admin, password:test123)

Once there we will be able to monitor all the transactions going through the Janus Gateway: calls, registrations or other.

Have you been wanting to build a custom application or assess one that is already on your website? We can definitely help you.

We have an experienced team ready & happy to help you out Contact us today!


Recent Blog Posts