Channel concepts

Channels are used to separate messages into different topics. They are the building block of creating a realtime application using the publish-subscribe pattern. Channels are also the unit of security and scalability. Clients should only ever be provided the capabilities for channels that they should have access to.

Messages contain the data that a client is communicating, such as the contents of an individual chat message, or an event that has occurred, such as updated financial information.

With basic Pub/Sub you create a channel, subscribe to it, and then publish messages to it. Most other Ably features utilize channels, or a group of channels, to provide additional functionality to your realtime applications.

Use a channel

To get started with implementing any feature, a client must first create or retrieve an instance of a channel. A channel is created, or an existing channel is retrieved from the Channels collection. You can only connect to one channel in a single operation.

Channels are identified by their unique name. The following restrictions apply to when naming a channel:

  • Channel names are case sensitive
  • They can't start with [ or :
  • They can't be empty
  • They can't contain newline characters

While Ably doesn't limit the length of channel names, keeping them under 2048 characters is recommended, since some older browsers have trouble with long URLs.

Use the get() method to create or retrieve a channel instance:

Device
Server