Channel Basics

A channel is a mechanism through which the data is transmitted from one device to another within PubNub. Channels exist on PubNub servers, and you interact with them (for example, by sending messages) using PubNub SDKs or directly via the REST API.

We are fast

Any device listening to a channel receives all messages in about 100ms regardless of their physical location in the world.

Channel Creation

You don't have to explicitly define or create channels on the server in advance. The channel is automatically created when you publish a message to a particular channel for the first time.

Channel Entity

PubNub SDKs use local representations of channels called Channel entities

Entity

A subscribable object within a PubNub SDK that allows you to perform context-specific operations.
to facilitate working with channels.

For more information, refer to Entities.

Channel Limits

There is no limit to the number of channels or the number of users in a channel you can have. A device can listen to thousands of channels simultaneously through a single open connection.

Channel Types

Channels represent any place where messages are sent and received. For example, a channel meant for 1-to-1 direct chat simply means that there are only two users using that channel. A group channel means there are two or more users using that channel.

Here are some useful channel configurations:

Direct channels for one-to-one in-app messaging between two users. You can make these channels private to keep the messages secure between the users.

Group channels for many-to-many in-app messaging between multiple users. For instance, a chat room for your family, or for a group of friends. You can make these channels made public to allow anyone to join, or make them private and only allow select users to join them.

Broadcast channels for announcements, polls, and other situations in which you want to broadcast messages in a one-to-many arrangement.

Unicast channels for poll responses, sensor inputs, location data, and other situations in which you want to aggregate messages in a many-to-one arrangement.

Channel groups allow you to bundle thousands of channels into a group that can be identified by name. When you subscribe to a channel group, you receive data from all the channels the channel group contains.

Channel Names

A channel name can be any alphanumeric string up to 92 UTF-8 characters. Channel names are unique per PubNub key set, and you can have the same name in another key, even within the same PubNub account. In other words, a PubNub key set is a namespace for your channels.

Invalid Characters

, : * / \ and Unicode Zero, whitespace, and non-printable ASCII characters.

Valid Characters

_ - = @ . ! $ # % & ^ ;

A period (.) is valid, however it's a special character that's used for wildcard features and is encouraged to be used strategically to leverage wildcard channel subscribe and Function wildcard channel binding.

Channel Name Validator

Check if your channel name is valid using our channel name validator.

Naming Conventions

When it comes to naming your channels, we recommend that you provide a prefix that identifies the purpose of the channel or the types of messages that will be sent over those types of channels.

Following that prefix with a . character further enhances the usefulness of the channel name concerning the wildcard features with several PubNub features, like wildcard subscribe, wildcard channel function binding, and advanced Presence configuration.

For further details on channel naming recommendations, refer to Channel Naming Conventions.

Securing Channels

You can secure your channels by controlling the access to them using PubNub's Access Manager which we will discuss in Access Control in the Security section. With Access Manager disabled, any client can send and receive messages on any channel. This is fine while you're learning to use PubNub but eventually, you'll need to secure your channels.

Last updated on