Skip to content

Transports ​

A transport is how a client reaches Janus. Janus speaks one JSON protocol (the Janus API) and one for operators (the Admin API). Each transport carries those same JSON messages over a different channel. Pick the one that fits who is calling: a browser, a server-side script, a message bus.

Each transport has its own config file in the configs folder, named janus.transport.<name>.jcfg, and each is off until its file turns it on. Janus does not start if no transport carries the Janus API: it stops with No Janus API transport is available. The key tables are in the transport files reference.

Which transport for which job ​

You are...UseWhy
A browser app (janus.js or your own)HTTP or WebSocketsBrowsers can only speak these two. WebSockets pushes events on the same socket; HTTP polls for them.
A backend that wraps Janus for its own clientsWebSocketsOne long-lived connection, no polling, any language has a client.
A script or curl on the same machineHTTPcurl http://localhost:8088/janus/info works with nothing installed.
A local process that wants no network portUnix socketsAccess is a file permission, not a firewall rule.
An IoT or event-driven system that already runs a brokerMQTTJanus subscribes to one topic and publishes on another.
A service platform built on a message queueRabbitMQRequests and replies are queued; the broker handles delivery and reconnection.
A C or embedded application that uses nanomsgnanomsgOne peer, one socket, no broker.

The transports run side by side. A session belongs to the transport that created it: its events come back on that transport only (see Events and sessions).

What each transport carries ​

HTTPWebSocketsUnix socketsMQTTRabbitMQnanomsg
Janus APIyes, POST on base_pathyes, subprotocol janus-protocolyes, general.pathyes, subscribe_topic and publish_topicyes, to_janus and from_janusyes, general.address
Admin APIyes, own port and admin_base_pathyes, own port, subprotocol janus-admin-protocolyes, admin.admin_pathyes, own topicsyes, own queuesyes, admin.admin_address
Events pushed to the clientno: the client long-polls with GETyes, as frames on the same socketyes, as messagesyes, on the publish topicyes, on the outgoing queueyes, on the same socket
Secure variantHTTPSwssnossl:// URLssl_enabledno
Janus is theserverserverserverclient of a brokerclient of a brokerbinds, or connects
One message isone HTTP bodyone text frameone datagram or packetone MQTT messageone AMQP messageone SP message
Run against the binary hereyesyesdatagram socket, on macOSyes, mosquitto 2.1yes, RabbitMQ 3.13yes, a hand-written SP peer
Janus Benchyesyesnononono

"Events" in this table means the asynchronous messages a client receives for its own sessions: plugin events, webrtcup, media, hangup, timeout. They are not the event handler events, which go to a third system whatever transport you use. Every transport also has a general.events switch that controls whether it reports its own connections to event handlers (a transport event).

What is the same on every transport ​

  • The JSON messages, their fields and the error codes. A request that works on one transport works on another once you add the transport's routing: HTTP puts the session and handle ids in the URL path, all the others put them in the JSON body as session_id and handle_id.
  • json in the transport file chooses how Janus writes replies: indented, plain or compact. The default is compact. HTTP, WebSockets, Unix sockets, MQTT, RabbitMQ and nanomsg all read it.
  • The Admin API needs admin_secret in each request (set in janus.jcfg), except info and ping. The core checks it, so it holds on every transport. I checked the missing-secret case over HTTP, WebSockets and Unix sockets; MQTT, RabbitMQ and nanomsg were exercised with the secret only.
  • api_secret and token authentication work through the core, so they apply to every transport.
  • A request that is not valid JSON gets error 454 as a reply.

Events and sessions ​

When you create a session on a transport, Janus remembers which transport it was. Everything the plugins push for that session goes back the same way. Close a WebSocket and the sessions it created end, unless reclaim_session_timeout in janus.jcfg keeps them for a while so that a new connection can send claim. Over HTTP there is no connection to close: a session ends when you destroy it or when session_timeout passes with no request and no long poll.

Known gaps ​

These apply to the transports as a group. The pages list the rest.

  • gap info does not list janus.transport.nanomsg although the nanomsg transport runs (checked: transports has http and websockets only). The C server lists it. The source registers the other five transports in that list.
  • gap The Admin request query_transport, which asks one transport for its own numbers (HTTP connection counts, for example), answers error 490 Not supported in this build: query_transport. This is the same gap the Bench reports.
  • gap session created events that go to event handlers carry a transport object in the C server. Here only sessions that were created over HTTP do. Sessions created over WebSockets, Unix sockets and nanomsg have {"name": "created"} alone. See event types.
  • gap The id in a transport event should stay the same for the life of a connection. For WebSockets, the connected and disconnected events of one connection carry different ids.

GPL-3.0-or-later, like the Janus gateway it ports.