Skip to content

samuel-duffield1/balena-zenoh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

balena-zenoh example

Two services on a balena device exchange messages through Zenoh using a pub/sub pattern. A third service (Zenoh router) is included for reference and is recommended when deploying multiple devices in a robotic swarm to reduce multicast traffic overhead.

How it works

By default, the publisher and subscriber do not require each other to be running—they automatically discover each other through Zenoh's multicast scouting mechanism. When the publisher publishes data, the subscriber (once it joins) will automatically receive it without any explicit broker coordination.

Optionally, you can configure them to use the zenoh-router as a central broker (similar to MQTT), which is useful in swarms where you want to minimize multicast traffic or where nodes may not have direct multicast connectivity. In that case, both services would connect to the router in client mode instead of relying on peer discovery.

Services

  • zenoh-router: Custom image built from the official Zenoh router base (eclipse/zenoh:1.7.1) with config baked in from router/zenoh.json5. Optional in this example (peer-to-peer discovery works by default via multicast), but recommended for multi-device deployments where a centralized router can reduce multicast discovery and routing overhead across the swarm.
  • publisher: Python + zenoh 1.7.1, publishes to demo/example every 2s. Discovers subscribers automatically via multicast or can connect to the router in client mode.
  • subscriber: Rust + zenoh 1.7.1, prints everything it receives on demo/example. Discovers publishers automatically via multicast or can connect to the router in client mode.

Quick start (balena)

  1. Install the balena CLI and log in (balena login).
  2. Push to your fleet: balena push <fleetSlug>.
  3. Tail logs: balena logs <deviceUUID> and you should see publisher and subscriber output.

Run locally with Docker

docker-compose up --build

You will see the publisher emit messages and the subscriber print them.

Config overrides

  • ZENOH_CONNECT: connect endpoint for publisher/subscriber (default tcp/zenoh-router:7447).
  • ZENOH_KEY: shared key expression (default demo/example).
  • ZENOH_VALUE: base text the publisher sends.

Notes

  • Port 7447 is published by the router so external tools can connect to the Zenoh network if needed.
  • Default device types in balena.yml can be adjusted to match your hardware fleet.

About

A repository demonstrating zenoh for multi-container state synchronisation on devices, without the need for a broker/router.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages