Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/heikkilamarko/nats-demo
NATS Demo
https://github.com/heikkilamarko/nats-demo
mqtt nats sveltekit websocket
Last synced: 8 days ago
JSON representation
NATS Demo
- Host: GitHub
- URL: https://github.com/heikkilamarko/nats-demo
- Owner: heikkilamarko
- License: mit
- Created: 2024-10-27T10:18:45.000Z (12 days ago)
- Default Branch: main
- Last Pushed: 2024-10-27T20:30:15.000Z (11 days ago)
- Last Synced: 2024-10-28T13:39:44.972Z (11 days ago)
- Topics: mqtt, nats, sveltekit, websocket
- Language: JavaScript
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NATS Demo
## Docker Compose
To start the services using Docker Compose, run the following command:
```bash
docker compose up --build -d
```| Service | Address |
| --------------- | --------------------------- |
| Demo UI | http://localhost:8080 |
| NATS Monitoring | http://localhost:8080/nats/ |## NATS CLI
### Create NATS Context
```bash
# Create a context for the demo account
nats context save --user admin --password S3c_r3t demo# Create a context for the sys account
nats context save --user sysadmin --password S3c_r3t sys# Select the demo context
nats context select demo# List all contexts
nats context ls
```### Publish Messages
```bash
# Publish 100 messages at 5-second intervals
nats pub demo.messages "hello {{.TimeStamp}}" --count 100 --sleep 5s > /dev/null &
```### Query Connected Users
```bash
# For all users
nats req demo.ping "" --replies 0# For one user
nats req demo.ping "" --replies 1# For three users
nats req demo.ping "" --replies 3
```### UI Configuration
#### Change Theme
```bash
# Set theme to light mode
nats kv put demo_kv theme "light"# Set theme to dark mode
nats kv put demo_kv theme "dark"
```#### Change Title
```bash
# Set a new UI title
nats kv put demo_kv title "New Title"
```#### Display KV Entries
```bash
# Show all key-value entries in the demo_kv store with values
nats kv ls demo_kv --verbose --display-value
```## MQTT
To send messages to the `demo/messages` topic, use [MQTT Explorer](https://mqtt-explorer.com/) or any other MQTT client.