---
title: Connecting to a Janus Media Server Using Janode – WebRTC.ventures
description: Janode enables you to secure and customize your Janus application for better performance. Tahir reviews some of the specific advantages to using Janode and runs some sample code to see it in action.
image: https://blog.webrtc.ventures/hubfs/Imported_Blog_Media/Connecting-to-a-Janus-Media-Server-Using-Janode.jpg
---

[Skip to content](https://blog.webrtc.ventures/2023/01/connecting-to-a-janus-media-server-using-janode#main-content)

![WebRTC.ventures](https://blog.webrtc.ventures/hubfs/logo-main-light.svg)

- [WebRTC Services](https://webrtc.ventures/webrtc-development-services/)
  
  Show submenu for WebRTC Services 
  
    - [Assess](https://webrtc.ventures/services/assess/)
    - [Build](https://webrtc.ventures/services/build/)
    - [Integrate](https://webrtc.ventures/services/integrate/)
    - [Test](https://webrtc.ventures/services/test/)
    - [Manage](https://webrtc.ventures/services/manage/)
    - [Migrating From Twilio Video](https://webrtc.ventures/twilio-video/)
- Our Partners
  
  Show submenu for Our Partners 
  
    - [Amazon Chime SDK](https://webrtc.ventures/partners/amazon-chime-sdk/)
- Stories of Success
  
  Show submenu for Stories of Success 
  
    - [Remote Video Interpreting Platform with Agent Routing](https://webrtc.ventures/successes/remote-video-translation-platform/)
    - [WebRTC to SIP Gateway for ASL Interpreters](https://webrtc.ventures/successes/webrtc-to-sip-gateway-for-asl-interpreters/)
    - [Audio Listening Device to Improve Surgical Outcomes](https://webrtc.ventures/successes/audio-listening-device-to-improve-surgical-outcomes/)
    - [Albania’s First Telemedicine Platform](https://webrtc.ventures/successes/albanias-first-telemedicine-platform/)
    - [Automated Video Storytelling with the Amazon Chime SDK](https://webrtc.ventures/successes/automated-video-storytelling-with-the-amazon-chime-sdk/)
    - [Large Scale Video Conferencing](https://webrtc.ventures/successes/large-scale-video-conferencing/)
    - [Broadcasting and Webcast Control Room](https://webrtc.ventures/successes/live-video-broadcasting-and-webcast-control-room/)
- WebRTC Resources
  
  Show submenu for WebRTC Resources 
  
    - [WebRTC Live](https://webrtc.ventures/webrtc-live/)
    - [WebRTC Tips](https://www.youtube.com/playlist?list=PLayYqdnyegt3QvxX-Rt6wbFIK8727Z5Oz)
    - [WebRTC.ventures Blog](https://webrtc.ventures/blog/)
    - [Migrating From Twilio Video](https://webrtc.ventures/twilio-video/)
    - [WebRTC.ventures Training Program](https://webrtc.ventures/webrtc-ventures-training-program/)
- [About Us](https://webrtc.ventures/our-team/)
  
  Show submenu for About Us 
  
    - [Blog](https://webrtc.ventures/blog/)
    - [Our Team](https://webrtc.ventures/our-team/)
    - [Jobs](https://webrtc.ventures/jobs/)

Open main navigation

Close main navigation

- [WebRTC Services](https://webrtc.ventures/webrtc-development-services/)
  
  Show submenu for WebRTC Services 
  
    - [Assess](https://webrtc.ventures/services/assess/)
    - [Build](https://webrtc.ventures/services/build/)
    - [Integrate](https://webrtc.ventures/services/integrate/)
    - [Test](https://webrtc.ventures/services/test/)
    - [Manage](https://webrtc.ventures/services/manage/)
    - [Migrating From Twilio Video](https://webrtc.ventures/twilio-video/)
- Our Partners
  
  Show submenu for Our Partners 
  
    - [Amazon Chime SDK](https://webrtc.ventures/partners/amazon-chime-sdk/)
- Stories of Success
  
  Show submenu for Stories of Success 
  
    - [Remote Video Interpreting Platform with Agent Routing](https://webrtc.ventures/successes/remote-video-translation-platform/)
    - [WebRTC to SIP Gateway for ASL Interpreters](https://webrtc.ventures/successes/webrtc-to-sip-gateway-for-asl-interpreters/)
    - [Audio Listening Device to Improve Surgical Outcomes](https://webrtc.ventures/successes/audio-listening-device-to-improve-surgical-outcomes/)
    - [Albania’s First Telemedicine Platform](https://webrtc.ventures/successes/albanias-first-telemedicine-platform/)
    - [Automated Video Storytelling with the Amazon Chime SDK](https://webrtc.ventures/successes/automated-video-storytelling-with-the-amazon-chime-sdk/)
    - [Large Scale Video Conferencing](https://webrtc.ventures/successes/large-scale-video-conferencing/)
    - [Broadcasting and Webcast Control Room](https://webrtc.ventures/successes/live-video-broadcasting-and-webcast-control-room/)
- WebRTC Resources
  
  Show submenu for WebRTC Resources 
  
    - [WebRTC Live](https://webrtc.ventures/webrtc-live/)
    - [WebRTC Tips](https://www.youtube.com/playlist?list=PLayYqdnyegt3QvxX-Rt6wbFIK8727Z5Oz)
    - [WebRTC.ventures Blog](https://webrtc.ventures/blog/)
    - [Migrating From Twilio Video](https://webrtc.ventures/twilio-video/)
    - [WebRTC.ventures Training Program](https://webrtc.ventures/webrtc-ventures-training-program/)
- [About Us](https://webrtc.ventures/our-team/)
  
  Show submenu for About Us 
  
    - [Blog](https://webrtc.ventures/blog/)
    - [Our Team](https://webrtc.ventures/our-team/)
    - [Jobs](https://webrtc.ventures/jobs/)
- [Contact us](https://webrtc.ventures/contact/)

[Contact us](https://webrtc.ventures/contact/)

 Jan 13, 2023 12:00:00 AM

# Connecting to a Janus Media Server Using Janode

[Tahir Golge](https://blog.webrtc.ventures/author/tahir-golge)

Share: [linkedin-in icon](http://www.linkedin.com/shareArticle?mini=true&url=https://blog.webrtc.ventures/2023/01/connecting-to-a-janus-media-server-using-janode) [X Twitter icon](https://twitter.com/intent/tweet?url=https://blog.webrtc.ventures/2023/01/connecting-to-a-janus-media-server-using-janode) [envelope icon](mailto:?body=https://blog.webrtc.ventures/2023/01/connecting-to-a-janus-media-server-using-janode)

[Janode](https://github.com/meetecho/janode) is a Node.js adapter for the open source [Janus WebRTC server](https://janus.conf.meetecho.com/). It enables users to develop an intermediary API between a Janus server and the client, providing a way to manage connections from the backend rather than the front end. This reduces the security and performance issues that arise from running the operations on the client side and exposing the Janus server directly to the client. 

Let’s take a look at some of the specific advantages to using Janode and then run some sample code to see it in action.

[![](https://blog.webrtc.ventures/hubfs/Imported_Blog_Media/Screen-Shot-2023-01-11-at-5_10_39-PM.png) ![](https://blog.webrtc.ventures/hubfs/Imported_Blog_Media/Screen-Shot-2023-01-11-at-5_10_39-PM.png)](https://blog.webrtc.ventures/hubfs/Imported_Blog_Media/Screen-Shot-2023-01-11-at-5_10_39-PM.png)

 Figure 1. Janode architecture

## Why Use Janode?

The biggest advantage of using Janode is that it provides a secure connection and less tightly coupled, better structured, and modern code where the operations are completed on the back end. The classical janus.js file is generally tightly coupled with the front-end code. This makes the code complex and hard to maintain and causes performance issues. Keeping the architecture separated and keeping the pieces simple is considered good practice. 

From a security perspective, janus.js performs all the heavy lifting on the front-end and leaves the Janus API exposed. In production grade software, this is not a good practice. For example, if the admin client can reach and call the create room kind of API directly to Janus, you rely on Janus’ secret and password mechanism. 

With an intermediary API in between, you can customize the protection of the server. For example, you can use JWT tokens for client-API interactions, restrict some API to client more efficiently, or limit reaching the server from outside the API. 

## A Summary of Advantages of Using Janode as the API Server

- Less tightly coupled code when compared with janus.js on the front end
- A more secure approach for using a media server 
- Allows developers to have a customizable API. You can add extra params, make merge operations, set defaults etc. with the customized API.
- It can act as a signaling server. Further complex applications may require much more customization on the signaling server, which Janode is also helpful. 
- Minimal dependencies to run
- Modern javascript code with node.js support (ES6, event emitters, destructuring, module ready, await/async) 
- Stateless
- Mimic Janus architecture, use the same plugin structure
- Clean, readable, understandable architecture and code

## Getting Started with Janode

To get started with Janode, you first need to deploy a Janus server and let Janode act as an API for the server. For deploying a Janus server, we recommend reading a previous blog post of ours, [Deploying a Hardened Janus Gateway](https://webrtc.ventures/2021/08/hardened-janus-gateway/).

For the purposes of this demo, we are using a [Docker](https://www.docker.com/) image and a docker-compose command to run Janus locally. If you don’t have Docker and docker-compose installed you can follow instructions [here](https://docs.docker.com/get-docker/) and [here](https://docs.docker.com/compose/install/other/) respectively to install these tools.

## Running the echoTest Implementation Demo

Next, we will run the [echoTest implementation demo](https://github.com/meetecho/janode/tree/master/examples/echotest) built with Janode. To do so, open a terminal window and — provided that you have the *git* cli tool installed (if not you can [install it from here](https://github.com/git-guides/install-git)) — pull the Janode source code from github:

`git clone https://github.com/meetecho/janode.git && cd janode`

Then, in the same terminal window, install the dependencies using npm and then navigate into example/echotest and install dependencies once again.

`npm install`  
`cd examples/echotest`  
`npm install`

At this point, you’ll need to configure the connection to the Janus server. To do so, locate a file under examples/echotest/src directory called config.template.js, and update it according to your Janus configuration and name it config.js. 

```
//examples/echotest/src/config.js
export default {
   janode: {
     address: [{
       url: 'ws://localhost:8198/',
       apisecret: 'secret'
     }],
     // seconds between retries after a connection setup error
     retry_time_secs: 10
   },
   web: {
     port: 4443,
     bind: '0.0.0.0',
     key: undefined,
     cert: undefined
   }
 };
```

JavaScript

Copy

In this example, Janus is running on Docker locally and mapped the port 8198 to Janus’ 8188 websocket default port and the config file is such. The docker file is pulled from this [repo](https://github.com/flutterjanus/JanusDocker), which the configuration only works on Linux OS:

`cd Janus`  
`docker-compose up -d # note option -d to start it in detached mode`

And now we just need to run the example. To do so, inside the echotest folder run `npm start`

The demo connects to a Janus server first through the Janode implementation. Then implements some websocket messages to let the client send some commands. The commands are redirected to the Janus if it is legit via Janode’s methods. 

It also acts as a signaling server, for example the trickle commands are as follows:

```
//examples/echotest/src/index.js
   // trickle candidate from the client
   socket.on('trickle', async (evtdata = {}) => {
     Logger.info(`${LOG_NS} ${remote} trickle received`);
     const { _id, data: trickledata = {} } = evtdata;
 
     if (!checkSessions(janodeSession, echoHandle, socket, evtdata)) return;
 
     echoHandle.trickle(trickledata.candidate).catch(({ message }) => replyError(socket, message, trickledata, _id));
   });
 
   // trickle complete signal from the client
   socket.on('trickle-complete', async (evtdata = {}) => {
     Logger.info(`${LOG_NS} ${remote} trickle-complete received`);
     const { _id, data: trickledata = {} } = evtdata;
 
     if (!checkSessions(janodeSession, echoHandle, socket, evtdata)) return;
 
     echoHandle.trickleComplete().catch(({ message }) => replyError(socket, message, trickledata, _id));
   });
```

JavaScript

Copy

Here, the express server created on the demo gets a trickle request from the front end client with the trickle data payload. The API then redirects the request to the Janus server via echoHandle.trickle() method. EchoHandle is initialized like so:

```
//examples/echotest/src/index.js
     try {
       echoHandle = await janodeSession.attach(EchoTestPlugin);
       Logger.info(`${LOG_NS} ${remote} echotest handle ${echoHandle.id} attached`);
```

JavaScript

Copy

And the events are implemented as follows:

```
//examples/echotest/src/index.js
// custom echoHandle events
       echoHandle.on(EchoTestPlugin.EVENT.ECHOTEST_RESULT, evtdata => {
         Logger.info(`${LOG_NS} ${echoHandle.name} echotest handle result event: ${JSON.stringify(evtdata)}`);
         replyEvent(socket, 'result', evtdata.result);
         Logger.info(`${LOG_NS} ${remote} result event sent`);
       });
 
       // generic echoHandle events
       echoHandle.on(Janode.EVENT.HANDLE_WEBRTCUP, () => Logger.info(`${LOG_NS} ${echoHandle.name} webrtcup event`));
       echoHandle.on(Janode.EVENT.HANDLE_MEDIA, evtdata => Logger.info(`${LOG_NS} ${echoHandle.name} media event ${JSON.stringify(evtdata)}`));
       echoHandle.on(Janode.EVENT.HANDLE_SLOWLINK, evtdata => Logger.info(`${LOG_NS} ${echoHandle.name} slowlink event ${JSON.stringify(evtdata)}`));
       echoHandle.on(Janode.EVENT.HANDLE_HANGUP, evtdata => Logger.info(`${LOG_NS} ${echoHandle.name} hangup event ${JSON.stringify(evtdata)}`));
       echoHandle.on(Janode.EVENT.HANDLE_DETACHED, () => Logger.info(`${LOG_NS} ${echoHandle.name} detached event`));
       echoHandle.on(Janode.EVENT.HANDLE_TRICKLE, evtdata => Logger.info(`${LOG_NS} ${echoHandle.name} trickle event ${JSON.stringify(evtdata)}`));
```

JavaScript

Copy

And from the front-end, just get the candidates from onIceCandidate of PeerConnection, then send it to the API for communication with Janus.

And that’s it. Now you have seen Janode in action with this example implementation of echoTest plugin. You can find the source code [here](https://github.com/meetecho/janode/tree/master/examples/echotest).

# Conclusion

Having an intermediary API between the front-end and your Janus server is important. Janode enables you to secure and customize your application for better performance. However, it is still a lot to digest and needs to be carefully architected to avoid problems.

***If you are looking for a customized WebRTC application or need help securing or scaling Janus,*** [***contact our expert team today***](https://webrtc.ventures/contact/)***!***

[CPaaS](https://blog.webrtc.ventures/tag/cpaas), [Managed Services](https://blog.webrtc.ventures/tag/managed-services), [Events](https://blog.webrtc.ventures/tag/events), [Video Conferencing](https://blog.webrtc.ventures/tag/video-conferencing), [Real Time Weekly](https://blog.webrtc.ventures/tag/real-time-weekly), [WebRTC Architecture](https://blog.webrtc.ventures/tag/webrtc-architecture), [Broadcasting](https://blog.webrtc.ventures/tag/broadcasting), [Medical](https://blog.webrtc.ventures/tag/medical), [WebRTC Live](https://blog.webrtc.ventures/tag/webrtc-live), [Showcase](https://blog.webrtc.ventures/tag/showcase), [Thoughts](https://blog.webrtc.ventures/tag/thoughts), [Vonage](https://blog.webrtc.ventures/tag/vonage), [Daily](https://blog.webrtc.ventures/tag/daily), [Jobs](https://blog.webrtc.ventures/tag/jobs), [Contact Centers](https://blog.webrtc.ventures/tag/contact-centers), [Telehealth](https://blog.webrtc.ventures/tag/telehealth), [Education](https://blog.webrtc.ventures/tag/education), [Technical](https://blog.webrtc.ventures/tag/technical), [General](https://blog.webrtc.ventures/tag/general), [Story of success](https://blog.webrtc.ventures/tag/story-of-success), [The WebRTC.ventures Blog](https://blog.webrtc.ventures/tag/the-webrtc-ventures-blog), [Testing](https://blog.webrtc.ventures/tag/testing), [Gaming](https://blog.webrtc.ventures/tag/gaming), [DevOps](https://blog.webrtc.ventures/tag/devops), [Symbl.ai](https://blog.webrtc.ventures/tag/symbl-ai)

## Related posts

[![](https://blog.webrtc.ventures/hs-fs/hubfs/Imported_Blog_Media/Deploying-a-Hardened-Janus-Gateway.png?height=200&name=Deploying-a-Hardened-Janus-Gateway.png)](https://blog.webrtc.ventures/2021/08/hardened-janus-gateway)

## [Deploying a Hardened Janus Gateway](https://blog.webrtc.ventures/2021/08/hardened-janus-gateway)

![Picture of Jen Oppenheimer](https://blog.webrtc.ventures/hs-fs/hubfs/Our-Team-Jen.jpg?width=50&name=Our-Team-Jen.jpg) [Jen Oppenheimer](https://blog.webrtc.ventures/author/jen-oppenheimer) 

 Aug 3, 2021 12:00:00 AM

If you’ve searched for a solution to scaling your WebRTC application, then more than likely you’ve...

[Read more](https://blog.webrtc.ventures/2021/08/hardened-janus-gateway)

[![](https://blog.webrtc.ventures/hs-fs/hubfs/Imported_Blog_Media/Building-a-Video-Conferencing-App-Using-Janus.png?height=200&name=Building-a-Video-Conferencing-App-Using-Janus.png)](https://blog.webrtc.ventures/2020/12/janus-webrtc-media-server-video-conference-app)

## [Building a Video Conferencing App Using Janus WebRTC Media Server](https://blog.webrtc.ventures/2020/12/janus-webrtc-media-server-video-conference-app)

[Alberto Gonzalez](https://blog.webrtc.ventures/author/alberto-gonzalez) 

 Dec 4, 2020 12:00:00 AM

For basic one to one video communications on the web, we could just use WebRTC and connect peers...

[Read more](https://blog.webrtc.ventures/2020/12/janus-webrtc-media-server-video-conference-app)

[![](https://blog.webrtc.ventures/hs-fs/hubfs/Imported_Blog_Media/Alberto-Gonzalez-to-speak-at-JanusCon-on-WebRTC-Janus-and-LLMLAMs.png?height=200&name=Alberto-Gonzalez-to-speak-at-JanusCon-on-WebRTC-Janus-and-LLMLAMs.png)](https://blog.webrtc.ventures/2024/03/alberto-gonzalez-to-speak-at-januscon-on-webrtc-janus-and-llm-lams)

## [Alberto Gonzalez to speak at JanusCon on WebRTC, Janus, and LLM/LAMs](https://blog.webrtc.ventures/2024/03/alberto-gonzalez-to-speak-at-januscon-on-webrtc-janus-and-llm-lams)

![Picture of Jen Oppenheimer](https://blog.webrtc.ventures/hs-fs/hubfs/Our-Team-Jen.jpg?width=50&name=Our-Team-Jen.jpg) [Jen Oppenheimer](https://blog.webrtc.ventures/author/jen-oppenheimer) 

 Mar 14, 2024 12:00:00 AM

The Janus WebRTC Media Server turns ten this year. Its author, Meetecho, is celebrating with...

[Read more](https://blog.webrtc.ventures/2024/03/alberto-gonzalez-to-speak-at-januscon-on-webrtc-janus-and-llm-lams)

### WebRTC.Ventures Services

...

- Assess
- Build
- Integrate
- Test
- Deploy & Manage

### Contact Us

...

**Video should be an opportunity, not a headache.**   
 We’re here to build, integrate, assess and optimize, test, and even deploy and manage your live video application. 

[Contact us](https://blog.webrtc.ventures/2023/01/connecting-to-a-janus-media-server-using-janode#contact)

### WebRTC Live

...

 View [past episodes](https://blog.webrtc.ventures/webrtc-live/) of our webinar interview series about the latest webRTC use cases and technical updates. Join our mailing list to learn about upcoming episodes! 

![WebRTC Live](https://blog.webrtc.ventures/hs-fs/hubfs/Template%20Images/widged-bannet.webp?height=90&name=widged-bannet.webp)

![logo-main-light](https://blog.webrtc.ventures/hubfs/logo-main-light.svg "logo-main-light")

We’re one of the few agencies in the world dedicated to WebRTC development. This dedication and experience is why so many people trust us to help bring live video application dreams to life.

 

### Let's get started!

###### **[Contact us today](https://webrtc.ventures/contact/)**

**[info@webrtc.ventures](mailto:info@webrtc.ventures)**

<https://www.linkedin.com/company/webrtc-ventures> <https://www.youtube.com/@WebrtcVentures>

### Join our mailing list

We don't e-mail often (a few times a month max), and it will be worth it when we do! Of course, we respect your privacy and will not share your contact information.

© 2023 WebRTC.ventures, an [AgilityFeat](https://agilityfeat.com/) company / [Privacy Policy](https://webrtc.ventures/privacy-policy//)

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Tahir Golge",
    "url" : "https://blog.webrtc.ventures/author/tahir-golge"
  },
  "dateModified" : "2024-04-03T18:21:37.903Z",
  "datePublished" : "2023-01-13T05:00:00.000Z",
  "headline" : "Connecting to a Janus Media Server Using Janode – WebRTC.ventures",
  "image" : [ "https://blog.webrtc.ventures/hubfs/Imported_Blog_Media/Connecting-to-a-Janus-Media-Server-Using-Janode.jpg" ],
  "mainEntityOfPage" : {
    "@id" : "https://blog.webrtc.ventures/2023/01/connecting-to-a-janus-media-server-using-janode",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://blog.webrtc.ventures/hubfs/logo-main-light.svg"
    }
  }
}
```