Realtime Messaging

Realtime Messaging

Send and receive messages cross-platform and cross-device with robust yet simple APIs for global publish/subscribe messaging.

PubNub DSN delivers Realtime Messaging APIs for mobile, web, IoT, desktops, and servers, enabling bidirectional low latency messaging to anywhere on the globe. Chock full of features and functionality, Realtime Messaging APIs are the most efficient, secure, and flexible way to connect every device on Earth.

What Comes with Realtime Messaging on the PubNub DSN?

Publish/Subscribe
Publish/Subscribe

The core of PubNub. Send and receive data to any number of connected devices in a ¼ second.

Multiplexing
Multiplexing

Efficient and optimized. Subscribe to 10,000s of streams with a single socket connection.

History
History

Never lose data. Store and retrieve message history, and use message catchup when disconnected.

TLS/AES
TLS/AES

Security is paramount. TLS connectivity and built-in AES256 libraries deliver secure point-to-point and end-to-end encryption.

Fuel For Developers. Fuel For Innovation.

APIs and infrastructure. PubNub DSN gets you to market and success, faster.



70+ SDKs For Development Without the Headaches

With SDKs for every language and every device, PubNub DSN works seamlessly between web, mobile, IoT, and everything in between.

Global Scale (We Mean It)

PubNub DSN connects 15 global points-of-presence to provide low-latency messaging between any number of devices and any number of users, anywhere on Earth.

Built and Battle Tested for the Real World

Hardened and secure, Realtime Messaging handles whatever the real world throws at it. PubNub automatically manages dropped connections, unreliable networking environments, firewalls, and comes standard with AES/TLS encryption.

How It Works:
Code Example

  • JavaScript
  • Android/Java
  • iOS
  • .Net
  • var pubnub = new PubNub({
  • subscribeKey: 'demo',
  • publishKey: 'demo',
  • });
  • pubnub.addListener({
  • message: function (message) {
  • console.log('message came in: ', message)
  • }
  • });
  • pubnub.subscribe({ channels: ['ChatRoomChannel'] });
  • pubnub.publish({ channel: 'ChatRoomChannel', message: 'Hello, world!' }, (publishStatus)=>{
  • if (publishStatus.error) {
  • console.error('Non 200 response', { publishStatus ) });
  • return ;
  • }
  • console.log('I just published my hello!');
  • });
  • PNConfiguration pnc = new PNConfiguration().setSubscribeKey("demo").setPublishKey("demo");
  • PubNub pubnub = new PubNub(pnc);
  • pubnub.addListener(new SubscribeCallback() {
  • @Override
  • public void message(PubNub pubnub , PNMessageResult message) {
  • System.out.println(message);
  • }
  • });
  • pubnub.subscribe().channels(Arrays.asList("chatChannel")).execute();
  • Map message = new HashMap();
  • message.put("Hello", "world!");
  • pubnub.publish()
  • .channel("chatChannel")
  • .message(message)
  • .async(new PNCallback<PNPublishResult>() {
  • @Override
  • public void onResponse(PNPublishResult result, PNStatus status) {
  • if (status.isError()) {
  • System.out.println(status);
  • } else {
  • System.out.println("Published!");
  • }
  • }
  • });
  • class Listener: NSObject, PNObjectEventListener {
  • func client(_ client: PubNub, didReceive status: PNStatus) {
  • if status.isError {
  • // Handle error
  • return
  • }
  • }

  • func client(_ client: PubNub, didReceiveMessage message: PNMessageResult) {
  • print("Received message!!! \(message.debugDescription)")
  • }
  • }
  • let myListener = Listener()
  • let configuration = PNConfiguration(publishKey: "demo", subscribeKey: "demo")
  • pubnub = PubNub.clientWithConfiguration(configuration)
  • pubnub.addListener(myListener)
  • pubnub.subscribeToChannels(["ChatRoomChannel"], withPresence: true)
  • pubnub.publish("Hello, world!", toChannel: "ChatRoomChannel", completion: { (status) in
  • if status.isError {
  • // Handle error
  • return
  • }
  • })
  • PNConfiguration pnConfiguration = new PNConfiguration();
  • // subscribeKey from admin panel
  • pnConfiguration.SubscribeKey = "demo"; // required
  • // publishKey from admin panel (only required if publishing)
  • pnConfiguration.PublishKey = "demo";
  • // secretKey (only required for access operations)
  • Pubnub pubnub = new Pubnub(pnConfiguration);
  • pubnub.Subscribe<string>()
  • .Channels(new string[] {
  • // subscribe to channels
  • "ChatRoomChannel"
  • })
  • .Execute();
  • string[] arrayMessage = new string[] {
  • "Hello",
  • "world!"
  • };
  • pubnub.Publish()
  • .Message(arrayMessage.ToList())
  • .Channel("ChatRoomChannel")
  • .ShouldStore(true)
  • .UsePOST(true)
  • .Async(new PNPublishResultExt(
  • (result, status) => {
  • // Check whether request successfully completed or not.
  • if (status.Error) {
  • // something bad happened.
  • Console.WriteLine("error happened while publishing: " + pubnub.JsonPluggableLibrary.SerializeToJsonString(status));
  • } else {
  • Console.WriteLine("publish worked! timetoken: " + result.Timetoken.ToString());
  • }
  • }
  • ));

"PubNub provided a simple-to-use SDK with clear documentation for every platform we needed. Furthermore, PubNub provided the necessary technical support for everything not covered in the documentation."

William Liang

Senior Computer Scientist

Full Case Study

"PubNub’s comprehensive feature set, ease of implementation, SDK support for Flash, Javascript and PHP, proven reliability and low latency were the main reasons why we chose PubNub over others. Also, since we only needed the solution for a short term, PubNub’s on-demand service model was perfect for our needs."

Reza Rosli

Technologist at Arc Worldwide Malaysia (for McDonald’s)

Full Case Study
eBay Buyer/Seller Chat
Logitech Home Automation Control
Adobe Collaborative Content Creation
Just Eat Notifications and Alerts
Ring Central SIP
PocketGems Multiplayer
Gaming
August Device Control and Monitoring
Glide Video Chat Signaling
Happiest Baby Device Control
and Monitoring
CBS Billboard content delivery
Kings Second Screen Interactivity
One Drop HIPAA-compliant Chat

Under the Hood

Efficient
  • Publish streams of data on unlimited channels -- even a channel per device.
  • Easy multiplexing and channel grouping allows subscribe to 10,000s of streams over a single socket connection.
  • Automatic compression of messages means optimal bandwidth usage.
  • Maintains always-on socket connections with optimal low-battery drain.
Fast
  • 250ms latencies worldwide.
Reliable
  • Auto catch-up on messages when device experiences unstable connectivity to the internet.
  • Automatic message bundling to handle deliverability on devices with slow or spotty network connections.
  • Unlimited storage for unlimited number of streams.
Secure
  • Device establishes secure tunnel to PubNub: no open listening ports required!
  • TLS connectivity and built-in AES256 libraries deliver secure end-to-end encryption.
  • Subscribe filtering lets devices listen to a subset of messages from a stream.

SDKs and Resources

Getting Started Tutorial
Getting Started Tutorial

Setting up PubNub and sending/receiving messages.

Read Basics Guide
SDKs + Documentation
SDKs + Documentation

70+ SDKs and comprehensive technical docs.

Read Technical Docs
Best Practices Playbook
Best Practices Playbook

How to use PubNub the right (and wrong) way.

Read Best Practice Playbook

Try PubNub Today

Connect up to 100 devices for Free