Learning MQTT with Golang
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Go to file
Drew Bednar 42ca31273c Updates for TLS 10 months ago
.mosquitto Pre-work for TLS usage 10 months ago
clock Doc string 11 months ago
cmd Pre-work for TLS usage 10 months ago
common Working through bugs 11 months ago
img Update to architecture doc 10 months ago
scripts Prepare to use TLS in local dev 12 months ago
.gitignore Prepare to use TLS in local dev 12 months ago
DESIGN_CONCIDERATIONS.md Pre-work for TLS usage 10 months ago
LICENSE Initial commit 12 months ago
Makefile Updates for TLS 10 months ago
README.md Updates for TLS 10 months ago
docker-compose.yaml Pre-work for TLS usage 10 months ago
go.mod Add unit tests to make and some clean up 10 months ago
go.sum Added local-dev broker and golang lib 12 months ago

README.md

Learn MQTT with Go

Learning MQTT with Golang by doing. This repo is a simple example of using a Golang application as a client (pub & sub) of an MQTT broker.

1883, Eclipse Mosquitto unsecured (opening the port on the internet is not recommended).

Architecture

mqtt-arch

Ideally I would like this application to resemble the above design. Conceptually, there

Development

For local development we use Mosquitto as our MQTT broker, with TLS enabled.

sudo apt install mosquitto-clients

First generate local development certs using:

make gen-local-tls-certs

This will create CA, server, and client certificates suitable for local development. Server and CA certs are created in ./.mosquitto/certs. The client cert is create in the project root.

Start the local development environment with:

make start-dev

Stop the local development environment with:

make stop-dev

Testing

Unit tests can be run with:

make test

Integration tests are run via:

make test-integration

Usage

To run the application end to end first start the development server:

make start-dev

Next we can start our subscriber. The following command connects to the TLS listener port.

go run cmd/subscriber/main.go --host 0.0.0.0 --port 8883

Design Considerations

See DESIGN_CONCIDERATIONS.md

Resources: