4

I am working on an IoT device. I have installed Eclipse Kura in raspberry pi 3 to use it as a gateway. I want to publish a message to Kapua server (installed in the same network) using Kura or directly using the raspberry pi. I have tried both methods.

1- Using Kura

I have followed the given instructions on GitHub Kura Kapua connection tutorial #780. After following these steps I am able to establish the Kura Kapua connection but unable to send data, Example.publisher package is also installed in Kura. I want to create a topic and publish data on that topic.

2- Using MQTT-Client library

I have installed the MQTT-Client library in raspberry pi and use the following commands to publish and subscribe the data.

To Publish :

sudo mosquitto_pub -h "broker-URL" -p "Port" -t "topic" -m "message" -u "user-name"-P "user-pass" -i "client-id"

To subscribe :

sudo mosquitto_pub -h "broker-URL" -p "Port" -t "topic" -u "user-name"-P "user-pass" -i "client-id"

this has the same behavior, It also establishes the connection but unable to create the topic and publish data.When I do the same for localhost it does send the message. I am using two different terminals to publish and subscribe.

Is there any method or example where I can actually send some data and observe at the other end using Kura or MQTT.

Misha Brukman
  • 12,938
  • 4
  • 61
  • 78
Ahmad Arif
  • 41
  • 4

1 Answers1

0

General knowledge

Correct connection parameters (if you followed the tutorial you mentioned) are:

-h localhost
-p 1883
-u kapua-broker
-P kapua-password
(not sure the doublequote is required)

Kapua uses has a specific topic format to grant access control over the topics. The semantic of the format is:

{account-name}/{client-id/{semantic-topic}

Depending on your privileges you can access different levels of topics.

The defaults user kapua-broker allows only to connect, publish and subscribe under:

{kapua-sys}/{connection-client-id}/#

You need more permissions to subscribe to other client-id topics.
The permission required to do that is:

data:view

Your example

First, it seems that you are using the published to subscribe. This is your command.

sudo mosquitto_pub -h "broker-URL" -p "Port" -t "topic" -u "user-name"-P "user-pass" -i "client-id"

Secondly credential, host, usenrname, password, and topic are all wrong (unless you "obscured" them before publishing to SO).

To make your test work you need to use the following commands,

Subscribe

mosquitto_sub -h "localhost" -p "1883" -t "kapua-sys/mosquitto_pub/my/test/topic" -u "kapua-sys" -P "kapua-password" -i "mosquitto_sub"

Publish

mosquitto_pub -h "localhost" -p "1883" -t "kapua-sys/mosquitto_pub/my/test/topic" -m "My test message" -u "kapua-broker" -P "kapua-password" -i "mosquitto_pub"

For the Kura example publisher, I don't know where could be the problem, due to lack of info. I'm assuming you are publishing or subscribing to a topic you cannot access to due to write/read permission on topics.


Hope that this help! :)

Coduz
  • 51
  • 2