I’ve recently been playing around with Snappy Ubuntu Core, and I thought it would be a nice exercise to try and package Mosquitto as a so-called “Snap”.
This blog post will give you a quick introduction to Snappy, and what it means to have a technology like Mosquitto available as a snap package.
Snappy Ubuntu Core
Ubuntu Core is a minimal Ubuntu distribution, that doesn’t come with the classical, APT-based, package manager.
Ubuntu Core is targeting cloud & IoT environments, therefore it is using an approach where the applications or services that one installs in a given distro, are self-contained “snaps”, that are completely isolated from the rest of the environment. If a snap depends on a shared library, this library will be bundled with the snap. If a snap needs to be granted rights beyond the scope of their default sandboxed container, it will be specified in the snap metadata. And so on.
Why does it matter for the Internet of Things?
Being able to transactionally update a system definitely makes sense for cloud environments, but it is also key for Internet of Things solutions. Even more so if you take into account how easy it is to fire up a new EC2 machine for a system you just crashed, vs. actually going on the field to troubleshoot an IoT gateway that went off the network after a failed update…
Furthermore, IoT gateways today are operating a very limited set of services, since there’s no clean and safe way to really turn them into extensible platforms, where any partner involved in developing a given solution would be able to run its own bits, in dedicated sandboxes. Application frameworks like Kura certainly enable such things at the application level, but we need solutions like Ubuntu Core for anything closer to the system.
Mosquitto on Snappy Ubuntu Core
If you have ever played with MQTT, there’s a good chance that you have used Eclipse Mosquitto as your broker. It is a very customizable, feature-packed, broker that has recently added support for MQTT over WebSockets. Mosquitto is available in source form, but it is also distributed in binary form and as a ready-to-use package in many Linux distros.
The Mosquitto Snappy package contains a WebSockets-ready version of Mosquitto 1.4.2 that can run on x64 or ARM architectures. Therefore, you are literally 2 minutes away from having an up-and-running Mosquitto broker on Microsoft Azure, Amazon EC2, or Google Compute Engine. Since Ubuntu Core is also available for the Raspberry Pi and the BeagleBone Black, you can install Mosquitto on those platform as well.
If you want to try it yourself on EC2, for example, you can follow this tutorial to bootstrap your Ubuntu Core image. Once you have a shell access to your Core server, simply run sudo snappy install mosquitto.kartben
, and Mosquitto will be automatically downloaded from the Ubuntu Software Store, and installed. WebSockets are enabled on port 8080 and as a matter of fact, I have also packaged a few extra resources with the broker to help you get started: if you open http://{myubuntucoreIP}:8080 in your browser, you will be granted with a web page that helps making sure you use the right connection settings, and also with a live visualization of your topics’ activity.
The post Running Eclipse Mosquitto on Snappy Ubuntu Core appeared first on Benjamin Cabé.