using Azure IoT Hub as a MQTT broker - mqtt

Our Current Deployment:
1) several back-end devices running an MQTT client connect to an opensource MQTT broker (Mosquitto)
2) Mosquitto is running on a Linux VM and acts as a broker and a communication point between back-end & front-end devices.
3) Several front-end devices (Mobile App / browser based GUI) connect to the broker. some of the front-end devices read & write to the broker (Sub & Pub) while some front-end only read (Sub)
4) Some front-end devices connect for a few minutes & some front ends are always connected.
5) Although the amount of data being transferred is a few kb, it is sometimes fast changing.
6) No TLS is used for the MQTT traffic & it cannot be enabled on the back-end devices.
This setup works for us, but I am looking for a way to scale up and was considering the azure IoT hub, but I am confused if the IoT hub can be used as a broker or I would need additional components to be deployed for acting as a MQTT broker ?

Azure IoT Hub is not a generic MQTT Broker. There is a built-in the device communications for MQTT protocol. More details can be found in the Using the MQTT protocol directly
For exploring the MQTT Devices (virtual devices) with the Azure IoT Hub (without the coding) can be used a small tool Azure IoT Hub Tester

Related

Mosquitto - subscribe to topics on a local bridge

I'm an MQTT newbie, so maybe this is obivous but I'm not getting it.
I've got IoT devices that publish data to a cloud MQTT broker. I can't change that. I want to be able to get the messages from the cloud broker and pass them to IoT Hub in Azure. Here's what I've done so far:
Configured a VM running CentOS to host my Mosquitto server
Installed Mosquitto and configured as a bridge to IoT Hub (IoTHubBridge)
Created a separate Mosquitto config to bridge to the cloud MQTT broker (CloudBridge)
Note that both Mosquitto bridge instances are running on the same VM.
So far, so good. IoT Hub can receive test messages that pass through IoTHubBridge and CloudBridge receives messages from the cloud broker. Here's where I'm stuck - how do I get messages to pass from CloudBridge to IoTHubBridge?
Thanks!
As hashed out in the comments.
There is no need for 2 MQTT brokers here. You should configure both bridges in a single broker, that way with the right topic declarations for the bridges messages should just flow between the IoT Hub and Cloud brokers.
This does assume that the topic/message structure for the cloud broker is compatible with what you need to send to IoT hub. The bridge will allow you to add/remove a prefix from the topic but not totally remap it. And there is no way to change the payload format.
If you need to make changes to the payload format or major changes to the topic structure then a bridge is not the right solution. You will need to create an application that subscribes to the cloud broker and then republishes the transformed message to the IoT Hub broker. There are many ways to do this in any number of languages but I might suggest you look at something like Node-RED if you are not already comfortable with an existing language/MQTT client combination.

Linking cloud based MQTT Broker and local MQTT Broker

I am quite new to MQTT implementations. I am managing to connect popular cloud based MQTT Brokers such thingsboard.io, Azure and AWS to send Sensor information to create dashboards for monitoring devices.
Problem
I have installed a local things-board broker to my local computer. But it is unable to reach other dashboards on the internet. Is it possible? Or is it only accessible within the local network?
It seems your doubt is more related to network connections. An MQTT broker will work in the same way, regardless it is working locally, in a fog server or in a cloud server. Obviously you will have to deal with access means: your clients/devices/applications must access the MQTT broker no matter where it is running. If you are running a local MQTT broker and it does not communicate directly with some cloud server, you can develop a specie of "gateway" only to send these data to the cloud or search for some tool that performs this task for you.
Below, you have some references regarding the working of MQTT and how to use it:
MQTT IoT Protocol complete tutorial - How it works with a demo
Using local MQTT broker for cloud and interprocess communication
MQTT Brokers/Servers and Cloud Hosting Guide
Creating an MQTT Broker With CloudMQTT
How to setup your own MQTT Broker

How to connect an existing MQTT broker with Thingsboard

I have a site using html, php, javascript and css in which I add my data from IOT devices using MQTT broker. Now I want to update it and I want to connect my MQTT broker with Thingsboard MQTT to manage the same data from both platforms. How can I succeed the communication between the two MQTT brokers?
You have to use the "Thingsboard IoT Gateway". In the Gateway you can set your external MQTT Broker and connect it over the Gateway to Thingsboard. I think thats the only solution. Just follow the instructions.

How to send message from mosquitto broker to azure IOT hub

I have installed mosquitto as a local broker. There are multiple devices which sends messages to the broker. I want that whatever message coming to mosquitto broker should be sent to azure IOT hub. Can anyone please refer to any document how to do that.
You have several approaches:
You can use one of the device client SDKs (depending on which
language you are using on your broker) to send data to IoT Hub
You
can use MQTT directly to communicate with IoT Hub, which will require
that you do specific things described in this document
(definitively recommend using the client SDK)

Allow access for MQTT on Ubuntu Server running on Azure

I have a Ubuntu Server 14.04 running on an Azure machine. I have installed MQTT broker on this Ubuntu Server. Moreover, I have multiple ESP8266 devices that are assumed to subscribe and publish to different MQTT topics via this broker. Now my problem is that when I connect two devices to Broker, one for receiving data and other for publishing, they work fine but as I try to connect one more device to broker all devices stop working and my ESPs just display this message "trying to connect Broker" over and over again.
(In endpoints of my machine I've added 1883 for HTTP, 443 for HTTPS and 22 for SSH)
My question is how I can allow multiple devices to communicate with MQTT broker running on Azure broker?
All client devices needs to have unique client ids. The situation you have described sounds exactly like what happens if all your esp8266 devices have the same hardcoded client id
MQTT clients get clientID as parameter before connection to provide uniqueness. ESP8266's has unique ChipID. So use it to hit the issue.
Here the example for Arduino firmware :
WiFiClient wifiClient;
PubSubClient mqttClient(wifiClient);
mqttClient.setServer(MQTT_BROKER, MQTT_BROKER_PORT);
String clientId = "IoTDevice-" + String(ESP.getChipId());
mqttClient.connect(clientId.c_str(), MQTT_USERNAME, MQTT_KEY);
Here is NodeMCU firmware example :
mqtt_cli:connect(MQTT_BROKER, MQTT_BROKER_PORT, 0, CALLBACK_FN);
mqtt_cli = mqtt.Client("IoTDevice-"..node.chipid(), 120, MQTT_USERNAME, MQTT_KEY);

Resources