IoT Network Deep Dive

8 min readJan 17, 2021

In my last article, I tried to give a gist of one of the many ways how a Secured IoT system could be deployed. In this article, I shall demonstrate another common way to secure your IoT Network by shielding it from the outer world.

I will also show, how web apps could interact with the MQTT broker which brings endless possibilities as raw sensor data could be accessed seamlessly in FrontEnd Apps.

The things I will be talking about are:

  • WebSocket protocol support for the Broker
  • Reverse Proxying the Broker

I will not be using something new, it’s the same Raspberry Pi IoT gateway, and a PC or Mac, that I have referred to in my previous articles.

Web-socket Protocol Support for MQTT Broker

NGINX as a reverse proxy for the MQTT Broker with WebSocket Support

MQTT is the most ideal IoT protocol for constrained devices as well as for unreliable networks. It’s the perfect way to send messages with very low network overhead. In the scenarios, where the devices need to communicate to the web apps on the cloud or mobile devices, MQTT natively cannot send and receive messages to the browser, e.g ChromeApp or on mobile phone.In that case, WebSocket protocol comes to the rescue. Wrapping up the MQTT protocol packets into the WebSocket packet enable the WebApps to leverage all MQTT features. The WebSocket protocol standardises the way the server can send content to the client without being first requested by the client, and allowing messages to be passed back and forth while keeping the connection open with very low overheads and in real-time. In this way, a two-way ongoing conversation can take place between the client and the server. The communications are done over TCP port number 80 (or 443 in the case of TLS-encrypted connections), which is of benefit for those environments which block non-web Internet connections using a firewall.

In the IoT scenario this encapsulation mechanism opens many possibilities like creating a web app to display sensor data in graphs, via push notifications, monitor device health and communicate in low bandwidth situations. All the modern web browsers support WebSockets, which makes them fully capable MQTT clients.

In this article, I will show you how simple it is to enable native WebSocket support in the…


Linux Enthusiast, Embedded systems, Quick Learner, IoT Developer