A channel is a mechanism through which the data is transmitted from one device to another within PubNub Realtime Communication Platform. Any device listening to a channel will receive all messages in less than 100ms in most cases, regardless of their location. Almost all of the PubNub APIs that you will use will involve channels as one of the parameters: sending, receiving, retrieving, securing, deleting, augmenting and more.
A channel name can be any alpha-numeric string up to 92 characters and are UTF-8 encoded. Channels names are unique per PubNub key and can have a same name in another key, even within the same PubNub account. In other words, a PubNub key is a namespace for your channels.
, : * / \ and Unicode Zero, whitespace and non-printable ASCII characters.
_ - = @ . ! $ # % & ^ ;
The Period A period (.) is valid, however it is a special character that is used for wildcard features and is encouraged to be used strategically to leverage these features: wildcard channel subscribe, wildcard channel granting and Function wildcard channel binding.
Dynamic & Unlimited
Channels do not have to be defined in advance; they are automatically created by the act of sending a message on the channel. A device can listen to thousands of channels simultaneously through a single open connection. And there is no limit to the number of channels that you can use with your PubNub API keys and there are no billing related consequences either.
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 freely send and receive messages on any channel. This is fine while you are learning to use PubNub but eventually, you will need to secure your channels.
Channels do not have a predefined type so they are able to be what you need them to be and flexible to change from one purpose to another as your requirements demand. In other words, channels can be used for many different purposes. This is called Channel Topology and here is a list of the most common types of topology:
- one-to-one: a private conversation between two people
- many-to-many: a conversation amongst a group of people
- one-to-many: a broadcast from one (or few) to many people
- many-to-one: a data aggregation from many devices