Racket MQTT client implementation based on paho.mqtt.c
This package provides an MQTT client implementation enabling Racket applications to exchange messages with an MQTT broker. This client implementation is based on paho.mqtt.c using Racket's foreign function interface ffi/unsafe
to wrap the synchronous MQTT library calls.
#lang racket/base
(require mqtt-client)
(mqtt/with-client ("localhost" "client1")
(mqtt/with-qos ('qos-1)
(mqtt/with-connection (#:keep-alive-interval 20
#:clean-session #t)
(mqtt/subscribe "some-topic")
(mqtt/publish "some-topic" "Hello world")
(mqtt/with-message-recv (topic payload)
(displayln topic)
(displayln payload)))))
- mosquitto-ffi An FFI binding of libmosquitto for racket
As this MQTT client wraps a library, this library must be present in the environment Racket is running in. E.g., on Ubuntu paho.mqtt.c can be installed by running:
sudo apt-get install -y libpaho-mqtt1.3
To exchange messages an MQTT broker must be available. Eclipse Mosquitto is a popular MQTT broker. To install Eclipse Mosquitto on Ubuntu run:
sudo apt-get install -y mosquitto
Verify the broker service is running be entering:
systemctl status mosquitto
To install this package from the internet, run
raco pkg install mqtt-client
To install this package from this source repository in the mqtt-client
directory run
raco pkg install
To remove this package run
raco pkg remove mqtt-client