MQTT integration with application server

Hi,

I would like to know the steps to integrate the Chirpstack application server with an external MQTT broker so that I can receive uplink data from my device on this MQTT broker and initiate downlink data from the broker to the application server.

I have installed Chirpstack version 4 using docker compose. After adding application and devices I navigated to integration tab to add MQTT integration. But the MQTT panel there displays “Get certificate”. If I click on it it displays “Generate MQTT certificate”. Then if I click on “Generate certificate” I get an error on the page " Error: Read mqtt ca_cert".

How do I integrate an external broker to talk to the application and devices I have added.

Thanks

Regards,
Harsha

MQTT integration:

https://www.chirpstack.io/docs/chirpstack/integrations/mqtt.html

Note that you will need to enable it (see [integration]):

https://www.chirpstack.io/docs/chirpstack/configuration.html

1 Like

Did you ever resolve this issue? If so, what was the solution?

All the “MQTT integration” button does is sign a certificate you can use to subscribe to the MQTT broker’s topics if you have already set up MQTT TLS by following these steps.

If you haven’t set up Mosquitto TLS, you can simply subscribe to your MQTT broker using mosquitto_sub -v -h broker_ip -p 1883 -t '#'.

If you wanted to pipe the MQTT topics to another MQTT broker you should look into MQTT-Mirror or MQTT-Bridge. Although this is really only necessary for some niche use-cases as most applications can simply subscribe to the MQTT-broker Chirpstack uses to view the events.

1 Like

Hello sir,

I have the same issue as Harsha, I struggle to “push” the data I receive on ChirpStack towards my MQTT broker. Since I’m completely new to the use of ChirpStack and almost every step related to data processing chains, I must say that I find the documentation about MQTT integration not very clear…
In practice, what must be done to actually integrate my MQTT broker with application server ?

Thanks
Regards

Your question isn’t exactly clear. When you say you are trying to “integrate your MQTT broker with application server” what do you mean by that?

Are you running Chirpstack V3 or V4? Chirpstack V3 is separated between an application server and a network server, and if this is what you mean by application server you should really just use Chirpstack V4, especially if you are new.

Is your goal to have an external application listen to the events on the Chirpstack MQTT Broker? or do you wish to send events to an external MQTT broker you have setup?

As you’re new I’m going to assume you are using V4, and are trying to add the integration events to Chirpstacks MQTT Broker, then have an external application subscribe to the Broker and see these events:

A bit of information first:

In the MQTT Event Types outlined in the documentation, the first four events: up/status/join/ack, should all already be being sent in your MQTT Broker, they are the four messages Chirpstack uses internally and requires to run, if you view your Chirpstack logs or subscribe to the MQTT Broker you should already see them. The rest of the events: txack, log, location, integration, are optional events that you can enable through the integrations section of your Chirpstack.toml. Note that the “integration event” is actually several events with the same topic format: application/<application_id>/device/<devEUI>/event/<event>.

To enable these optional events, all that is necessary is to fill in the following configuration section in your chirpstack.toml, if you do not have an integration section you can add it:

[integration]
  enabled=["mqtt"]
  [integration.mqtt]
    server="tcp://$MQTT_BROKER_HOST:1883/"
    json=true

If you wish to instead send the optional events to an external MQTT Broker you could change the location in the server= line.

Then to view these events your application must subscribe to one of the brokers topics, either a specific topic or all of them using the “#” wildcard topic, you must figure out how to do this yourself for the purposes of your application. For debugging, you can subscribe to the MQTT broker yourself using:

mosquitto_sub -v -h broker_ip -p 1883 -t '#'

If you have done the steps bconway outlined here to enable TLS for your MQTT Broker using self-signed certificates, then you must use the mosquitto_sub command with the “MQTT Integration” certificates given through the web UI.

I hope this wasn’t too much of an information dump but it really is necessary to understand how Chirpstack works before trying to build anything on top of it. Good luck!

First of all thank you very much for your answer, now things make more sense.

I’m running ChirpStack V4 and I’d like to send events to an external MQTT broker that I have setup localy for instance.
There is one thing I still haven’t figured out : where should I write the command lines (for example about the configuration section in chirpstack.toml) ? Until now, my access to Chirpstack was limited to my web browser since I’m working on a pre-existing LoRa network (my school network), and I don’t see where I could write anything. I guess it’s a foolish question, so sorry to bother you !

thanks a lot
Sincerely,

No worries man, I’m happy to help.

Unfortunately if you only have access to the web-interface you won’t be able to set up the MQTT Broker Integration.

If you do have access to ssh into the server running Chirpstack there is a main configuration called chirpstack.toml, the location of this file depends on your system and how it was setup (I.E what machine is it running on? Ubuntu, Raspberry Pi? Is it setup in Docker?).

Regardless of what the setup is though it shouldn’t be too hard to poke around and find the chirpstack.toml file. In there you need to enable the mqtt integration and configure it as I showed in the previous message, then restart Chirpstack (again doing this depends on the system).

For reference my setup is on a Ubuntu VM, and I set it up using docker following these instructions, and the path to my chirpstack.toml file is:

/home/local/chirpstack-docker/configuration/chirpstack

I believe in non-docker Ubuntu setups the path is:

/home/(your-user)/etc/chirpstack/chirpstack.toml

Well, I work on macOS and also use Docker to run ChirpStack (I followed the steps depicted in the documentation). By doing so I was able to access the files (chirpstack.toml file particularly), and I also specified the region (EU868 for me). But then, how can connect to the Chirpstack server of my school using my old ID and password via Docker ?

I don’t understand, did you set up the schools Chirpstack server and no longer have access? Or are you saying you have a second (irrelevant) server running on your mac?

If you have never accessed the computer the schools server is running on (either through ssh or physically using the computer) then you would need to request access from whoever runs it in your school.

Regardless there’s nothing I can do to help you access the schools Chirpstack server if you don’t know how to.

Yes, I have a second server running on my mac but it is obviously irrelevant. Okay, I see. I’m not familiar with ssh, could you explain briefly the way it works ?

Thank you very much for sharing your knowledge man.

Most computers allow you to SSH (standing for secure shell) into them, although if your school’s IT department is any good it will probably be blocked by a firewall.

All that SSH’ing does is allow you to have remote access to the computer through it’s command line (meaning no user interface, like using your Mac through the terminal app). To do this open terminal and use the command:
ssh user@ip-or-dns-of-server

user needs to be replaced with a username of an account on the computer and the ip-or-dns-of-server needs to be replaced with either the IP or the DNS of the server (DNS stands for domain name server, some examples are: google.com or forum.chirpstack.io, note that the DNS does not include HTTP://). It will then prompt you for your accounts password and if correct you will be allowed access into the computers command line.

I am assuming you do not know the IP/DNS of your Chirpstack server (although it should be the same as the DNS you use to access the web interface so you could try that) and secondly I assume the server will be blocked from external traffic (this means you might be able to SSH to the machine if you are on the school wifi, but probably won’t be able to from any other wifi).

If these are true then again I cannot help you access the server. Although feel free to ask more questions.

Happy Hacking, :wink:

1 Like