https://github.com/frenchbread/rust-mqtt-client
Sample client application for publishing and subscribing to messages served by EMQX broker.
https://github.com/frenchbread/rust-mqtt-client
Last synced: about 1 year ago
JSON representation
Sample client application for publishing and subscribing to messages served by EMQX broker.
- Host: GitHub
- URL: https://github.com/frenchbread/rust-mqtt-client
- Owner: frenchbread
- License: mit
- Created: 2022-09-07T13:18:14.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-09-07T13:40:49.000Z (almost 4 years ago)
- Last Synced: 2025-02-11T19:36:33.160Z (over 1 year ago)
- Language: Rust
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
MQTT Rust app
====
> Client application for publishing and subscribing to messages served by EMQX broker.
[Create](https://cloud-intl.emqx.com/console/) own cloud instance of EMQX Broker for testing or [download](https://www.emqx.io/downloads) and run locally.
### Setup
Rename `.env.template to .env` provide env variables.
- **BROKER_HOST** - EMQX broker host
- **CLIENT_NAME** - client name
- **PUB_TOPIC** - topic to publish to e.g. testtopic/1
- **SUB_TOPICS** - list of topics to subscribe to (separated by comma)
- **QOSS** - QOS value(s) for topics subscribtions (separated by comma)
- **USERNAME** - emqx broker user username
- **PASSWORD** - emqx broker user password
### Build
```
❯ cargo build
```
### Subscribe
Run this command to subscribe to topic(s):
```
❯ ./target/debug/sub
```
### Publish
And this to publish 5 "hello world" messages:
```
❯ ./target/debug/publish
```
### todos
- [x] move sensitive variables to env
- [x] decouple code for connection to separate module and reuse for both pub&sub
- [ ] integrate with tauri application
### LICENSE
[MIT](https://github.com/frenchbread/rust-mqtt-client/blob/main/LICENSE)