Sending data from Node-Red to Cumulocity Plattfrom

Dear all

Product/components used and version/fix level:

I’m using a Raspi 4 with “Node Red” 3.0.2. Further, I have a “Cumulocity IOT Plattfrom Free Trial” running.

Detailed explanation of the problem:

I’m trying to connect over MQTT and create a device according the description “Hello MQTT” under “MQTT client examples” from Cumulocity IOT Guide.
cumulocity(.)com/guides/device-integration/mqtt-examples/#hello-mqtt

I use a “mqtt out” node configured as follows:
Topic: s/us
Payload: 100, My first MQTT device, c8y_MQTTdevice
mqtt-Server: env979ZXY.eu-latest.cumulocity(.)com/mqtt
User: env979ZXY/emailadress_for_cumulocityIOT_Login
PW: Password_for_cumulocityIOT_Login

Error messages / full error message screenshot / log file:

The Node-Red Flow with the mqtt-client, can not connect to the cumulocity plattfrom and also not create a device in the cumulocity platfrom over SMARTREST.

Does anybody has an example how to connect and create a device and measurement with node-red, mqtt and SMARTREST?

Thank you for your help or any ideas, what I could try.

Regards Martin

1 Like

Hi Martin,

a very good approach would be to subscribe to s/e such that you see error message while creating.
What’s the output on that?

Best,

1 Like

Here are a few pointer:

  • try mqtt.eu-latest.cumulocity.com as the MQTT Host
  • Use port 1883 or 8883
  • Fix your payload, remove the blank spaces after commas 100,My First MQTT Device,c8y_MQTTdevice
  • User + PW look fine so far

And check what s/e prints out.

1 Like

Thank you for the tips.
The problem is, that I cannot subscribe to any topic or publish something, becasue Node-Red can not connect to the Cumulocity Platfrom.

I have now added an additional User and PM in the cloud and tried all findable combinations for URL, but I can’t connect.

Neither with Node Red or with Python code as shown in the “MQTT client examples” descriptions.

Does somebody knows, if it is even possible to cennect with MQTT or is this depreciated?

Hi,
just tried it out, it’s definitely working. Try changing:

  • Server from eu-latest.cumulocity.com to mqtt.eu-latest.cumulocity.com (note the mqtt. prefix at beginning)
  • changing protocol from MQTT V3.1 (legacy) to MQTT V3.1.1
  • activate the TLS checkbox (that’s important, Node Red won’t connect on port 8883 otherwise)

Neither with Node Red or with Python code as shown in the “MQTT client examples” descriptions

It’s strange that also Python code does not connect though. Is this running within a company network/VPN where network policies might block MQTT? To be sure, maybe try running it in e.g. a mobile hotspot or a network you’re sure there’s nothing blocking outgoing MQTT traffic.

Thank you for your test.

I have changed the config. acc. your advice. But I still can not connect.

Is it maybe not working, because I have a Trial Version?

MQTT is working for sure, becasue this device with Node-Red is also connected to AWS IoT Core over MQTT.

Regards

Settings looking similar as on my side now and it should also work on trial tenants. If that’s helpful, I can PN you the flow I’m using tomorrow.

Could be that this issue is about your User. Can you login to the UI and navigate to Administration > Accounts > Users > your “hofmar” user and paste a screenshot? I would like to see if the global roles on the right side are editable + the assigned roles of this user.

Note that:

  • In general there’s a bootstrapping process via MQTT where you would register your client on Cumulocity and receive a device-user back. Devices are expected to use this user, especially in productive environments. The process is described here: Startup Phase
  • For testing purposes you can also use your personal user. But you have to make sure it is not a User managed by an external authorization/SSO Server. The screenshot above should tell if that’s the case.

Thank you for your help.
Everything is checked and editable.
Yes, please send me the flow if possible.
If you have a flow for http request with REST, please also send it to me, because this is also not working.

You can try 1883 and deactivate TLS for testing purpose, just to make sure that this is not a TLS configuration issue.
Everything else looks fine.

1 Like

I remember that there was something about not working if alias is used. Could you remove the alias and try it with the username instead.

I’ve sent you a flow with MQTT and HTTP Nodes that did work for me.

If you have a flow for http request with REST, please also send it to me, because this is also not working.

That’s an important hint that I would prioritize here. Can you do API Calls with this User at all (e.g. using Postman, Insomnia or any other API client)? What’s the server response for your failing requests?

Thank you for the response.
@Stefan_Witschel: I have tried with 8883 and 1883, but a connection is not established.
@Murat_Bayram: I have tried with alias “Martin” and user “hofmar” from the same user, but a connection was not established.

@Korbinian_Butz: I will try your flows and give you an aswer. But the user looks like it should work?

Thank you.

Regards

It seems you have connectivity issues… If you can’t connect via python or node-red it seems that some firewall is blocking your outgoing connection to cumulocity on port 8883, 1883.

Have you tried connecting to another public mqtt Broker such as Hive MQ to check that outgoing 8883 and 1883 is working?

https://www.hivemq.com/mqtt/public-mqtt-broker/

@Murat_Bayram @Stefan_Witschel : The same node red device is connected to AWS IOT Core over MQTT and a MQTT Broker in the internet. So that should not be the issue. I will try again later :slight_smile:

Thank you for the support.

Thank you for the support, now I was able to connect.
It seems, that first the problem was, that I have tried to connect with a user with external origin.
Then later the problem was a typo in the password from the new user.
It helped to do the API call and receive the error, to find out, that there was a typo.

Thank you very much for your effort in supporting me.

Regards Martin