/

Consuming Services As a Subscriber


If you are coming from the previous section then you have a working Red5 Pro cluster in place with at least one stream publishing to it.

Now that the stream is publishing and available subscriber clients may be interested to subscribe to it. However they don't know the host address of the edge that they should subscribe to.

Consuming Services As A Subscriber

Once again Stream Manager comes to the rescue by providing stream information to the subscriber client via REST API call. The subscriber client will need to make a READ STREAM REST call to stream Manager using a scope name, stream name and the action parameter (subscribe).

  • Scope name is the Red5 application/context name that a client connects to. The default scope name to be used is live
  • Stream name is the name of the publishing stream
  • Action is a query string parameter which defines the client's request type: broadcast or subscribe

Requesting Stream Subscribe Information

Use stream manager's READ STREAM REST API to request for an edge server.

The combination of scope name and stream name should be unique for each streaming event.

Request Format

http(s)://{host}:{port}/streammanager/api/<api-version>/event/{scopeName}/{streamName}?action=subscribe

Response Format

{
  "name": "<stream-name>",
  "scope": "<stream-scope>",
  "serverAddress": "<edge-host-address>",
  "region": "<region-code>"
}

Connecting To Server To Subscribe

Having received a successful response from Stream Manager with stream subscribe information we can now consume the stream using a subscriber client.

The stream subscribe information received from the REST response can be used by different types of subscribing client(s) as shown below.


Android Client

Property NameValue
host
context
port8554
stream

iOS Client

Property NameValue
host
context
port8554
stream

Flash Client

Property NameValue
Connection URLrtmp://:1935/
stream

WebRTC Stream Manager Proxy Subscribing

WebRTC requires using the Stream Manager proxy feature to bypass the secure origin requirement, to be able to publish.

To learn more about proxy and configuring WebRTC client to work with proxy please see the Stream Manager Proxy Guide.


Notes

  • You cannot make a subscribe request for a stream if it is not publishing
  • If a stream stops publishing the subscribers must re-query the Stream Manager for stream details