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.


8 thoughts on “PubNub versus MQTT

  1. Hello Peter,
    not directly link to pubnub, but perhaps an alternative…if no solution!

    I’m using Arduino IDE and tried different MQTT library with the following steps device publish a state (for example status=50) through mqtt (retain)
    2. my device is disconnect, unplug…
    3. an app send a command to the device (cmd=100)
    4. my device is replug and reconnected
    5. my device subscribe to cmd and state

    the pb is that nothing is received (I’d like to have the last status and the last cmd), ie cleansession=false
    Do you know a client (library) that support cleanssesion?
    Is there a way to have the last state of a topic ? (without new publication)

    Thanks a lot!
    PS : Reading your blog for a year : it’s really the most complete!! 🙂

    1. I have never used the retain status…the MQTT server must support this and therefore I guess be connected to a database to store info for later passing on – and the client must support all the modes. As I understand it TUANPM supports all modes.

  2. I looked at Pubnub for around about 45 seconds before I did that sum in my head too 10 * 60 * 60 * 24 * 31 = 26 million messages a month, $149 what an absolute waste of my time. google should put that service to the bottom of the search results. I could rent 6 whole MQTT servers of my own per month for that.

  3. I’ve had a look at PubNub and it looks great for sending messages like MQTT and there are lots of options for developing solutions on many platforms, there’s too much to learn for me, I’ll stick to pushbullet for instant notifications from Node red on my phone.

  4. Pete, don’t be lost too long, please.
    I’m a kind of addicted person. Have an abstinence syndrome without my five’o’clock reading. 🙁
    Hope you are ok.

    1. Hi Vladimire – well, I’ve read more and I’m not convinced this has anything to offer that MQTT doesn’t. It was pointed out to me that the actual specification of MQTT doesn’t include storage etc, but in reality – Mosquitto as available free and as I’ve documented elsewhere how to put on a Raspberry Pi and similar – is just fine – it just “works”.

Comments are closed.