Subscribing with WebRTC

Subscribing with WebRTC

When subscribing to a Provisioned stream on the Stream Manager using the WebRTC Subscriber from the Red5 Pro WebRTC SDK, you will first request the Edge endpoint to access the stream and then use one of the variant stream names to start subscribing.

It is dependent on your project requirements, but if running an ABR with different broadcast quality settings, we recommend first subscribing to a variant that is in mid-range. The Edge server will handle.

WebRTC clients require using the Stream Manager proxy in order to publish. This essentially means that you will request to start publishing on the streammanager proxy webapp which is then transferred to the Origin and then propegated on the Edge(s). The reason is that browser vendors require WebRTC broadcasts to be served over SSL. In an autoscale environment in which Origins and Edges are spun up and down dynamically based on load, it can be unfeasible to also have certs on each of those Origins and Edges. As such, you can subscribe through the Stream Manager proxy which will be served over SSL.

You will request the Edge from the Stream Manager using one of the variant stream names. The JSON response is then used to start a WebRTC subscriber.

Given that the response to the GET request at:


is the following:

  "serverAddress": "",
  "scope": "live",
  "name": "mystream_2"

Your initialization configuration for an RTCSubscriber will look like the following (in following with the above examples):

(function (red5prosdk) {

  var subscriber = new red5prosdk.RTCSubscriber()
    host: 'yourstreammanager.com',
    app: 'streammanager',
    streamName: 'mystream_2',
    protocol: 'wss',
    port: 443,
    connectionParams: {
      host: '',
      app: 'live'
    subscriptionId: 'subscriber-' + Math.floor(Math.random() * 0x10000).toString(16)
  .then(function () {
  .catch(function (e) {


The above is a very basic configuration. Your webapp may need additional configurations depending on requirements and deployment.

When utilizing the Stream Manager proxy for WebRTC subscriptions, you assign the top-level configuration app property as streammanager, and provide a connectionParams object that details the endpoint to proxy to.

In this example, the mystream_2 stream is requested. In doing so, the subscriber is started with a mid-level variant. As conditions improve or worsen the stream variant will be dynamically switched to higher or lower quality, respectively.