# Node red and mqtt on ibm cloud (bluemix)?

**URL:** <https://discourse.nodered.org/t/node-red-and-mqtt-on-ibm-cloud-bluemix/3023>\
**Category:** General\
**Created:** [10 September 2018 21:20 UTC](https://discourse.nodered.org/t/node-red-and-mqtt-on-ibm-cloud-bluemix/3023 "2018-09-10T21:20:43Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![j0hncc](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@j0hncc](https://discourse.nodered.org/u/j0hncc)\
**Post date:** [10 September 2018 21:20 UTC](https://discourse.nodered.org/t/node-red-and-mqtt-on-ibm-cloud-bluemix/3023/1 "2018-09-10T21:20:43Z")

</div>

Is it possible to use node red and mqtt on a bluemix instance _without_ using the ibm "Managed devices" framework/environment?

I am trying to set up a flow like this to send arbitraty messages but can't get the mqtt nodes to work. I think I am not understanding the URL security settings and several apikey/authtokens in IBM dashboards/app/services/connections.

```auto
[{"id":"6789aac7.ae4fb4","type":"inject","z":"fb19899.5845a78","name":"","topic":"hello","payload":"this is the msg","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":140,"wires":[["fb6272af.4b74c","a649b47d.668408"]]},{"id":"fb6272af.4b74c","type":"mqtt out","z":"fb19899.5845a78","name":"mqtt hello","topic":"hello","qos":"","retain":"","broker":"f98794d8.8d00c8","x":540,"y":140,"wires":[]},{"id":"eaca990c.d96658","type":"debug","z":"fb19899.5845a78","name":"Msg Received by MQTT Node","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":430,"y":300,"wires":[]},{"id":"a649b47d.668408","type":"debug","z":"fb19899.5845a78","name":"Attempted Send to MQTT","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":410,"y":220,"wires":[]},{"id":"768d5d50.a63994","type":"mqtt in","z":"fb19899.5845a78","name":"","topic":"hello/#","qos":"0","broker":"f98794d8.8d00c8","x":150,"y":280,"wires":[["eaca990c.d96658"]]},{"id":"f98794d8.8d00c8","type":"mqtt-broker","z":"","name":"MyMqtt","broker":"6ykzkv.messaging.internetofthings.ibmcloud.com","port":"8883","tls":"","clientid":"a:6ykzkv:1","usetls":true,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

```

Almost all the docs I find talk about it from the "managed device" (IBM framework) perspective, so before I plow further into it, I'm asking if what I'm trying to do is even possible.

Thanks,  
John

---

<div class="post-metadata">

**Author:** ![michaelblight](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/michaelblight/32/445_2.png) [@michaelblight](https://discourse.nodered.org/u/michaelblight)\
**Post date:** [11 September 2018 02:15 UTC](https://discourse.nodered.org/t/node-red-and-mqtt-on-ibm-cloud-bluemix/3023/2 "2018-09-11T02:15:06Z")

</div>

Are you asking if you can use NR & Bluemix with your own MQTT broker? If so, the answer is yes - that's what I'm doing using Mosquitto on my network. I assume your current code is using Watson IOT, which I have not used.

---

<div class="post-metadata">

**Author:** ![j0hncc](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@j0hncc](https://discourse.nodered.org/u/j0hncc)\
**Post date:** [11 September 2018 03:40 UTC](https://discourse.nodered.org/t/node-red-and-mqtt-on-ibm-cloud-bluemix/3023/3 "2018-09-11T03:40:39Z")

</div>

Thanks, but no, I am wanting to connect clients to the mqtt broker which is running on (my instance of) bluemix. (e.g. [6xyZzy.messaging.internetofthings.ibmcloud.com:1883](http://6xyZzy.messaging.internetofthings.ibmcloud.com:1883) )  
And then send/receive messages on arbitrary topics like topic="greet msg"="hello world" (NOT the IBM-device-managed format like topic="iot-2/type/myDeviceType/id/myDeviceID/cmd/command/fmt/text").

I will post also on [developer.ibm.com](http://developer.ibm.com)...

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [11 September 2018 06:07 UTC](https://discourse.nodered.org/t/node-red-and-mqtt-on-ibm-cloud-bluemix/3023/4 "2018-09-11T06:07:57Z")

</div>

No, you cannot use the IoT Platform as a generic mqtt broker. You need to register your devices and follow the topic name requirements of the platform.

---

<div class="post-metadata">

**Author:** ![j0hncc](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@j0hncc](https://discourse.nodered.org/u/j0hncc)\
**Post date:** [11 September 2018 14:39 UTC](https://discourse.nodered.org/t/node-red-and-mqtt-on-ibm-cloud-bluemix/3023/5 "2018-09-11T14:39:29Z")

</div>

Hmm, I was afraid of that. Thanks.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [11 September 2018 14:58 UTC](https://discourse.nodered.org/t/node-red-and-mqtt-on-ibm-cloud-bluemix/3023/6 "2018-09-11T14:58:12Z")

</div>

you can run your own broker of course - either via a separate machine - eg a softlayer instance - or inside Node-RED using [https://www.npmjs.com/package/node-red-contrib-mqtt-broker](https://www.npmjs.com/package/node-red-contrib-mqtt-broker) - but you'll have to ensure you secure it yourself of course.

---

<div class="post-metadata">

**Author:** ![loki-cmd](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/loki-cmd/32/10037_2.png) [@loki-cmd](https://discourse.nodered.org/u/loki-cmd)\
**Post date:** [8 July 2019 17:14 UTC](https://discourse.nodered.org/t/node-red-and-mqtt-on-ibm-cloud-bluemix/3023/7 "2019-07-08T17:14:06Z")

</div>

@michaelblight Can you tell me what IP address did you use to connect your NR to MQTT?  
What I did was first use NR on my RasPI and then connect it to ESP32 to pass sensor data and control LED using my localhost IP.  
Now, I copied the same flow onto my Bluemix Node-Red starter pack but my MQTT Broker fails to connect. Can you please help me?

---

<div class="post-metadata">

**Author:** ![michaelblight](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/michaelblight/32/445_2.png) [@michaelblight](https://discourse.nodered.org/u/michaelblight)\
**Post date:** [8 July 2019 22:29 UTC](https://discourse.nodered.org/t/node-red-and-mqtt-on-ibm-cloud-bluemix/3023/8 "2019-07-08T22:29:25Z")

</div>

If you're wanting to connect Bluemix to your local MQTT broker, it will need to be visible to the Internet and accessed via your public IP address. Tread carefully here, because you don't want to accidentally make your whole home network available to anybody on the Internet.

---

<div class="post-metadata">

**Author:** ![loki-cmd](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/loki-cmd/32/10037_2.png) [@loki-cmd](https://discourse.nodered.org/u/loki-cmd)\
**Post date:** [9 July 2019 09:01 UTC](https://discourse.nodered.org/t/node-red-and-mqtt-on-ibm-cloud-bluemix/3023/9 "2019-07-09T09:01:38Z")

</div>

@michaelblight I had given the same IP address of my RasPI on which my MQTT Broker is installed. This previously worked when my NR was running on RasPI but I could not view sensor data without connecting to the same WiFi network. Now, when I tried using IBM cloud and uploading the same flow on NR, it fails to connect to the same MQTT Broker installed on my RasPI.  
Security is not a concern for me as of yet, because I am uploading just sensor data (i.e. using DHT22).  
I am aiming to create a webpage that I can share with anyone, and he/she can view the sensor data on their on device sitting at their home. Can you please guide me how could I do so?

---

<div class="post-metadata">

**Author:** ![loki-cmd](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/loki-cmd/32/10037_2.png) [@loki-cmd](https://discourse.nodered.org/u/loki-cmd)\
**Post date:** [9 July 2019 09:03 UTC](https://discourse.nodered.org/t/node-red-and-mqtt-on-ibm-cloud-bluemix/3023/10 "2019-07-09T09:03:45Z")

</div>

@michaelblight Also for some reason I cannot install node-red-contrib-mqtt package on my Node-red-starter pack on IBM cloud. Is that might be the reason this connection fails?

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [9 July 2019 09:15 UTC](https://discourse.nodered.org/t/node-red-and-mqtt-on-ibm-cloud-bluemix/3023/11 "2019-07-09T09:15:46Z")

</div>

> [@loki-cmd](#):
>
> Security is not a concern for me as of yet, because I am uploading just sensor data (i.e. using DHT22).

Sorry, security is a concern as soon as you allow access from the internet onto any computer. After 20 seconds your computer will already have been scanned. You need to ensure you understand what you are doing (also the risks of doing this) and have secured the pi BEFORE you allow access from the internet to any machine.

But going back to your challenge...

You had the sensors connected to your local MQTT broker?  
The sensors are on your local network?  
You then want to view the sensor data outside of your network?  
Where are you thinking of hosting the webpages to do this?

---

<div class="post-metadata">

**Author:** ![loki-cmd](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/loki-cmd/32/10037_2.png) [@loki-cmd](https://discourse.nodered.org/u/loki-cmd)\
**Post date:** [9 July 2019 10:04 UTC](https://discourse.nodered.org/t/node-red-and-mqtt-on-ibm-cloud-bluemix/3023/12 "2019-07-09T10:04:52Z")

</div>

@ukmoose I am sorry, I never thought of security that way. I will definately look into it. As of the problems I am facing, my sensor (DHT22) is connected to ESP32 which has been given the MQTT Broker IP address installed on Raspberry Pi 3. These both are connected to the same WiFi network. If I run Node-red from my RasPI, it works fine and my MQTT Broker widget also connects on the MQTT Broker IP (192.168.137.130:1883) and then I can view my sensor data on 192.168.137.130:1883/ui.  
Now, I tried running same flow on IBM cloud but my MQTT Broker fails to connect to the MQTT Broker running on RasPI. Can you please help me? Are there any other way I can provide others to view my sensor data without connecting to the same link? Any webpage I can use to show the sensor data online?

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [9 July 2019 10:15 UTC](https://discourse.nodered.org/t/node-red-and-mqtt-on-ibm-cloud-bluemix/3023/13 "2019-07-09T10:15:53Z")

</div>

You could use Node-RED on your Pi to redirect data to IBM Cloud

So  
`[sensor]--[MQTT Broker]--[Node-red on Pi]--[IBM Cloud]`

see [https://developer.ibm.com/recipes/tutorials/simulating-a-device-and-publishing-034messages034-to-ibm-iot-platform-from-a-nodered-034watson-iot034-platform-node/](https://developer.ibm.com/recipes/tutorials/simulating-a-device-and-publishing-034messages034-to-ibm-iot-platform-from-a-nodered-034watson-iot034-platform-node/)

---

<div class="post-metadata">

**Author:** ![loki-cmd](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/loki-cmd/32/10037_2.png) [@loki-cmd](https://discourse.nodered.org/u/loki-cmd)\
**Post date:** [9 July 2019 10:36 UTC](https://discourse.nodered.org/t/node-red-and-mqtt-on-ibm-cloud-bluemix/3023/14 "2019-07-09T10:36:33Z")

</div>

@ukmoose Thank you, I will look into it and get back to you asap!

---

<div class="post-metadata">

**Author:** ![loki-cmd](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/loki-cmd/32/10037_2.png) [@loki-cmd](https://discourse.nodered.org/u/loki-cmd)\
**Post date:** [10 July 2019 05:43 UTC](https://discourse.nodered.org/t/node-red-and-mqtt-on-ibm-cloud-bluemix/3023/15 "2019-07-10T05:43:16Z")

</div>

@ukmoose Hey, thanks for the link. I tried running that and it worked fine. I wanted to ask you is there a way I can have GUI view for the sensors similar to one we get on node-red because using Watson IoT platform we get only sensor values as integer.  
Here is an image of how my sensor data looks like, can you suggest any way I can view the same or similar GUI view for sensors without connecting to the same network?

![57%20AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/f/f54a384978f702e04e5867cd7ff5bc2e24be0805.png)

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [10 July 2019 07:00 UTC](https://discourse.nodered.org/t/node-red-and-mqtt-on-ibm-cloud-bluemix/3023/16 "2019-07-10T07:00:59Z")

</div>

Try googling “IBM cloud node-red” 🙃

---

<div class="post-metadata">

**Author:** ![loki-cmd](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/loki-cmd/32/10037_2.png) [@loki-cmd](https://discourse.nodered.org/u/loki-cmd)\
**Post date:** [10 July 2019 07:44 UTC](https://discourse.nodered.org/t/node-red-and-mqtt-on-ibm-cloud-bluemix/3023/17 "2019-07-10T07:44:40Z")

</div>

@ukmoose Hey, I don't need to google about it cause I have already tried it. That was my very first query, as I was not able to connect my MQTT broker when using node-red on IBM cloud.  
Can you help me with this or I need to google that too? Thanks anyway 🤔

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [10 July 2019 08:01 UTC](https://discourse.nodered.org/t/node-red-and-mqtt-on-ibm-cloud-bluemix/3023/18 "2019-07-10T08:01:22Z")

</div>

If you have data sending from your local devices to the Watson IoT platform, then you can run an instance of Node-RED in the IBM Cloud, connect it to the IoT platform and get your data.

The main issue all along has been where your broker is. If it is running on your local network, then applications running in the cloud cannot see it unless you open up your home network and take all the necessary security precautions.

If you run the broker in the cloud (or use a publicly hosted service like IBM IoT) then you can connect to it from both your home network and other applications running in the cloud.

There are lots of examples of running Node-RED in IBM Cloud here: [https://developer.ibm.com/components/node-red/](https://developer.ibm.com/components/node-red/)

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [10 July 2019 08:01 UTC](https://discourse.nodered.org/t/node-red-and-mqtt-on-ibm-cloud-bluemix/3023/19 "2019-07-10T08:01:56Z")

</div>

Found on the front page of the search.

[https://www.rs-online.com/designspark/put-your-thing-on-the-internet-using](https://www.rs-online.com/designspark/put-your-thing-on-the-internet-using)

---

<div class="post-metadata">

**Author:** ![loki-cmd](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/loki-cmd/32/10037_2.png) [@loki-cmd](https://discourse.nodered.org/u/loki-cmd)\
**Post date:** [10 July 2019 10:04 UTC](https://discourse.nodered.org/t/node-red-and-mqtt-on-ibm-cloud-bluemix/3023/20 "2019-07-10T10:04:38Z")

</div>

@knolleary I tried finding a way to install mqtt broker on ibm cloud, but I have not found anything usable. Do you know some way I can install MQTT broker and run NR on IBM cloud? My MQTT broker fails to connect every time I deploy my flow.

[Next page](https://discourse.nodered.org/t/node-red-and-mqtt-on-ibm-cloud-bluemix/3023.md?page=2)
