Verify the connection to the device
This tutorial shows how to monitor the connection to the Nureva® audio devices over the local network. The heartbeat endpoint will return data every few seconds if there is a connection. Once an initial request is made, data will start streaming at a regular interval.
If you have already connected to Start Sound Location Data Stream endpoint, you do not need to connect to the heartbeat endpoint to verify connectivity.
What can be done with the API?
The heartbeat endpoint is a basic server-sent events (SSE) endpoint. This verifies the connection to the Nureva audio device. Instead of polling for device connectivity, please subscribe to this, or any other SSE endpoint. The return type for SSE endpoints is text/event-stream
, which means that the endpoint will return a stream of text. You may parse this text to extract the data and event name. The return type of data for this endpoint is also text, and will always return .
.
To illustrate, this sample response below will be returned every 5 seconds.
event: heartbeat
data: .
retry: 5000
Minimum role required: none
The heartbeat endpoint does not require authorization, so no role is required.
Overview
- Send a request to the heartbeat endpoint to open an SSE connection.
- Parse the stream events.
Instructions
Step 1 - Send a request to open an SSE connection
Use heartbeat streaming endpoint to open an SSE connection:
- Set the path with the IP address of the Nureva audio device followed by
/api/v1/heartbeat
. - Update the headers to include
Nureva-Client-Id
as key andintegration_app_name
as the value. - Update the headers to include
Nureva-Client-Version
as key and0.0.1
as the value. - Send the GET request.
The code sample below is a request to connect to the SSE data endpoint for the device with the IP address of 10.0.0.1
.
curl --request GET \
--url https://10.0.0.1/api/v1/heartbeat \
--header 'Nureva-Client-Id: integration_app_name' \
--header 'Nureva-Client-Version: 0.0.1'
- If the call is successful, an HTTP status code of 200 OK will be returned.
Step 2 - Parse the stream events
Once the SSE connection is established, events will be emitted on intervals of 5 seconds.
The example response below indicates that the Nureva audio device is connected with your integration:
.
The heartbeat events will continue streaming until the connection is closed.
If an error occurs, the SSE connection will respond with an appropriate error code.
Tutorial complete!
You now know how to verify the connectivity to the Nureva® audio devices over the local network.
Updated 1 day ago