What are Janus sessions and handles?

874 views
Skip to first unread message

Riley Lester

unread,
Jul 10, 2022, 1:36:11 PM7/10/22
to meetecho-janus
Since the Google group requires aproval to post I first asked this on stackoverflow here: https://stackoverflow.com/q/72925999/19518955 . If you don't welcome cross posting let me know and I'll delete my SO question. 

I've started experimenting with Janus, and for most part it's easy to understand. But one thing that isn't really documented is exactly what sessions and handles are. By looking through the code I see that `createSession()` is called within the Janus.js Janus() constructor to connect user over http/ws, and when this connection is successfull `createHandle()` is called within Janus.attach() when attaching to a plugin, so by this I'm left to guess that sessions are associated with the users connection with Janus service (over Websocket or REST for example), and handles are associated with the users connection with the plugin (datachannel, media tracks, etc). But this is just guessing from the code, and to make matters more confusing the documents hint that a user can have multiple sessions at once (more than one tab? more than one peerconnection?) and that users can also have more than one handle (multiple datachannels/media stream within a single peerconnection? multiple peerconnections? [docs aren't specific that peerconnections are linked to sessions - that is just a guess]). Can anybody detail what Janus sessions are as well as Janus handles? Thank you.

edit: looking into the Janus server side API and server side code I see that it uses multiple definitions of handles (gateway handle, plugin handle, core handle). Plugin handle I can understand, since this will basically be the context of a connection into a specific video room etc, so multiple handles from the plugin perspective would then allow a user to participate in more than one room at once within the same plugin, which is understandable. But when trying to fit the idea of core/gateway handles into this it breaks how I thought I understood it. At that point they start to resemble the context of how I think sessions are being used. So this not only changes how I need to understand Janus handles but also Janus sessions as well :/

second edit: While surfing the Janus codebase I also found that 'seesion' tends to be used in multiple contexts as well (user, plugin, ext). This matters because I am brainstorming the possibility of creating Janus plugins. So my main questions:

  • When if comes to higher level usage, ie Janus.js and Janus's basic JSON API's, what is the most important concepts to understand in Janus sessions and Janus handles?
  • On the deeper level, what are plugin sessions/plugin handles (as well as gateway handles, etc) and how do they differ from the concepts in what could be considered higer level userspace sessions/handles?


Lorenzo Miniero

unread,
Jul 11, 2022, 4:36:23 AM7/11/22
to meetecho-janus
When we talk of sessions and handles, we mean exclusively sessions/handles as seen from a user, so not the core internals. They're both covered here:

Typically a session is something as a user you establish with the Janus core. Within the context of that session, you can setup one or more handles, where a handle is an abstraction of a connection with a plugin. Each plugin can have at max a single PeerConnection associated with it, so if you need, e.g., 2 PeerConnections with the VideoRoom, you need two handles.

L.

Lorenzo Miniero

unread,
Jul 11, 2022, 4:37:20 AM7/11/22
to meetecho-janus
Sorry, typo there: I meant "Each handle can have at max a single PeerConnection associated with it"

L.
Reply all
Reply to author
Forward
0 new messages