I have a Raspberry Pi that tells you through web sockets and a sensor the amount of electricity you are spending in real time.

I created an iPhone app as a front-end that basically just paints the info received through the web socket.

Evidently, this does not work when you are not in the same local network and now I am testing different technologies to solve this problem.

First option is a VPN, when when selling this to hundreds of customers, that probably don't have advance technical skills, this will not work.

Second option: Ngrok. I use this for accessing my macmini jenkins outside my office, works really well, however, its price, about 2 or 3 dollars per year, is too much for a IOT device.

Third option: Nabto (www.nabto.com). It seems it is what I need, and only a few cents/pence per year. But, integrating that library in my app is a bit painful.

Does anyone have more ideas about how to solve this problem or libraries/solutions I could use?

By the way, does anyone what technology is used by Philips Hue?

  • I would use a public MQTT service. There are some free MQTT services. PS Next time you post, check how the text is formated before posting.
    – MatsK
    Feb 18, 2019 at 15:15
  • Can be MQTT used for real time apps? My app sends hundreds of messages per second containing data that the app uses to draw a graph, that is the reason I use web sockets instead of http web services. I thought MQTT was more like http services, I mean, a messaging protocol not in real time.
    – Ricardo
    Feb 18, 2019 at 15:34
  • I didn't see the need for real time when measuring power consumption, and you are right about MQTT, its a messaging protocol.
    – MatsK
    Feb 18, 2019 at 15:39
  • I see another problem, it seems that approach requires an Internet connection all the time, it is less reliable than nabto (that works in the same network if there is no internet connection), or not having anything.
    – Ricardo
    Feb 18, 2019 at 15:48
  • Have a look at RabittMQ, Ref.: rabbitmq.com that is well suited for distributed models, high volumes of messages and more.
    – MatsK
    Feb 18, 2019 at 16:03

1 Answer 1


You can (should) use a lightweight machine to machine protocol like MQTT which is designed for this purpose.

Documentation is sufficient and you can find a suitable library for a variety of programming languages.

You will find useful information about this messaging protocol on


You need to install a broker on a physical/virtual server in order to subscribe/publish on topics and access data out of the local network. In this case, mosquitto comes very handy and well structured which you can find enough information about it on


Also, you can always use mosquitto's free broker in order to test your solution (It is not reliable for production scale), the broker address is :


Finally, you can use MQTT based cloud platforms such as links mentioned below




  • Thanks Sina. Can I use MQTT for real time apps? Just to send a constant flow of data in order to paint a diagram in the app in real time.
    – Ricardo
    Feb 19, 2019 at 17:58
  • 1
    Of course , depending on your server's performance and your internet speed. Please bear in mind, 1) you can set up your own Physical/Virtual Private server or 2) you can use an online platform, but the first scenario is more customizable and scalable. Feb 20, 2019 at 19:51
  • I am going to try that. Last question, what about if the local network does not have Internet connection?
    – Ricardo
    Feb 20, 2019 at 22:09
  • 1
    In this case you can not access your devices out of the local network (as I know), still your devices can communicate to each other through a local network and a server (like the Raspberry Pi you've mentioned). setting up a Mosquitto broker on a raspberry pi is easy and there are a lot of instructions regarding your RPi's operating system on the internet. check out switchdoc.com/2018/02/… Feb 21, 2019 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.