Category Archives: pubnub

PubNub versus MQTT

Today I’ve been playing with PubNub. This is a something-vaguely-like MQTT like service.   Now if you’ve read my articles you’ll know I’m not keen on public services for IOT – what happens if they go down? That’s your fridge on the blink… but this one looks interesting because they have backup servers on multiple continents. But let’s read on…

A simple example of the use of Pubnub is as follows:

I’m in Node-Red and I’ve added the Pubnub nodes. All they want off me are my credentials which I got when signing up for a free PubNub account.


I put the two long numbers into one of the nodes – and that’s it. Sending a timestamp or simply “hello” payload to the lower PubNub node results in the message appearing instantly on the upper node and going out to debug on my screen. You don’t get any simpler.

So – how does the free option work? Well, you can connect 100 devices an send up to a million messages a month. Data is encrypted.  So how good is 1 million messages a month?  I probably send maybe 10 MQTT messages a second over my two setups – one in Spain one in the UK and so 10 * 60 * 60 * 24 * 31 = 26 million messages a month – so clearly were I to consider this as an alternative, the free account would be no good – and sadly the next step up is 5 million messages at $149 a month…. and then it gets really silly at $799 a month for 30 million messages… so clearly this is not going to replace unlimited MQTT messages on my own server for free.. However, for sending stuff back and forth at a more leisurely pace, say no more than one message every 3 seconds on average, it is free. Messages can be up to 32k in length but as that includes any encoding they suggest knocking that down by maybe 5k. To keep all messages in a single TCP packet for speed, consider keeping messages down to <1.5k.  Message length includes the name (topic).  Unlike MQTT topics you can’t use slashes. Prohibited characters in names include ,/\.*:

Oh and one BIG difference between MQTT and Pubnub is that in MQTT you can elect to simply listen for certain messages with wildcards – doesn’t work that way in PubNub… you get everything coming in for that particular key. Still – nice to know it is there.

I did kind of expect there would be a load of Android test applications to use PubNub in the way you use Pushbullet – but I’m not seeing anything at first glance. Am I missing something?

For more information go to – LOTS of SDKs including stuff for ESP8266.