# Message hub client example This example shows how a simple rust client can be implemented for communication with the message hub. The protobuf client will connect to the message hub server and publish on a device-owned interface periodically. The published data will be a value corresponding to the uptime of the client, together with the UUID of the node sending the data. It will also accept data published on server-owned interfaces and print to screen the received values. **N.B.** Make sure you satisfy the [common prerequisites](./../README.md#common-prerequisites) and have completed the [common configuration](./../README.md#common-configuration) before starting this example. ## Start the example client(s) The following command can be used to start a single client. ``` cargo run --example client -- ``` Run this command multiple times in separate terminals to start multiple clients. And attach them as nodes to the message hub server. For ease of implementation, all the clients will register the same interfaces. While, an unique `` should be passed to each client. ## Check published data from the client(s) We can now check that the data published by our clients has been correctly received and stored in the Astarte cluster. Let's use `get-samples` as follows: ``` astartectl appengine --appengine-url http://api.astarte.localhost/appengine --realm-key _private.pem \ --realm-name devices get-samples \ org.astarte-platform.rust.examples.datastream.DeviceDatastream -c 10 ``` Where `` is your realm's name, `` is the device ID from which the data has been received and `` is the endpoint we want do observe. This will print the latest published data from the device that has been stored in the Astarte Cloud instance. To print a longer history of the published data change the number in `-c 10` to the history length of your liking. ## Receive data from the server published with the client With `send-data` we can publish new values on a server-owned interface of our local Astarte instance. The syntax is the following: ``` astartectl appengine --appengine-url http://api.astarte.localhost/appengine \ --realm-management-url http://api.astarte.localhost/realmmanagement \ --realm-key _private.pem --realm-name devices send-data \ org.astarte-platform.rust.examples.datastream.ServerDatastream ``` Where `` is your realm name, `` is the device ID to send the data to, `` is the Astarte type of the chosen endpoint, `` is the endpoint to send data to and `` is the value to send. We can observe how all the clients will print out a message with the content of the incoming data each time we publish some. Since all of our clients are subscribed to the same interfaces this is to be expected.