Nyx Stream
Nyx Stream is the Nyx server responsible for real-time data streaming used for live visualization in Nyx Lab (charts, waterfall, ...). It implements a Nyx-specific streaming specification. INDI focuses on device control and standard properties, while Nyx Stream provides a dedicated, high-throughput channel for continuous data streaming.
Specifications
Nyx Stream uses a binary framing format to transport stream messages.
Stream Frame Format
| Field | Offset (bytes) | Size (bytes) | Type | Description |
|---|---|---|---|---|
| MAGIC | 0 | 4 | u32 | Frame identifier (0x5358594E) |
| HASH | 4 | 4 | u32 | Stream identifier (Murmur2 32-bit hash of "{device}/{stream}") |
| SIZE | 8 | 4 | u32 | Payload size in bytes |
| PAYLOAD | 12 | PAYLOAD_SIZE | bytes | Stream payload |
Total frame size:
\[ \mathrm{FRAME\_SIZE} = 12 + \mathrm{PAYLOAD\_SIZE}\]
All integer fields are encoded as little-endian.
Payload Format
The payload is a concatenation of \(n_{\mathrm{fields}}\) field blocks:
| Block Field | Size (bytes) | Type | Description |
|---|---|---|---|
| FIELD_HASH | 4 | u32 | Field identifier (Murmur2 32-bit hash of the field name) |
| FIELD_SIZE | 4 | u32 | Field value size in bytes |
| FIELD_VALUE | \(\mathrm{FIELD\_SIZE}\) | bytes | Raw field value |
Payload size:
\[ \mathrm{PAYLOAD\_SIZE} = \sum_{i=0}^{n_{\mathrm{fields}}-1} \left(8 + \mathrm{FIELD\_SIZE}_i\right)\]
All integer fields are encoded as little-endian.
Installing Nyx Stream
See the “Insallation” page.
Configuring Nyx Stream
In /etc/nyx-stream/config.json:
{
"tcp_url": "tcp://0.0.0.0:8888",
"http_url": "http://0.0.0.0:9999",
"mqtt_url": "mqtt://127.0.0.1:1883",
"mqtt_username": "",
"mqtt_password": "",
"poll_ms": 10
}tcp_url: Network endpoint used by Nyx Node to publish data streams to Nyx Stream.http_url: Network endpoint used by Nyx Lab to discover and subscribe to streams (REST API and WebSocket interface).mqtt_url: Network endpoint of the MQTT broker.mqtt_username: Username for authenticating to the MQTT broker (empty means “no username”).mqtt_password: Password for authenticating to the MQTT broker (empty means “no password”).poll_ms: Server processing interval, in milliseconds. It defines the maximum effective update rate of the streaming system.
Nyx nodes must not publish samples at a higher frequency than
poll_ms.
Nyx Stream API
Base URL: http://<host>:<port>
Authentication is optional and depends on server configuration.
When enabled, all requests must include a token query parameter.
Authentication
Authentication is derived from the MQTT credentials configured on the server. mqtt_username and mqtt_password are used to compute the HTTP / WebSocket access token.
Query parameter
| Name | Type | Required | Description |
|---|---|---|---|
| token | string | No | Access token required when authentication is enabled. |
Token computation
The token is computed as follows:
- Concatenate the MQTT credentials using the form:
<username>:<password>. - Compute the SHA-256 hash of this string.
- Take the first 8 bytes of the hash.
- Encode them as 16 lowercase hexadecimal characters.
Example (pseudocode)
token = hex(sha256(mqtt_username + ":" + mqtt_password)[0: 8])Subscribe to a Stream (WebSocket)
Subscribe to a real-time data stream and receive binary frames over WebSocket.
Endpoint
GET /streams/{device}/{stream}Path parameters
| Name | Type | Description |
|---|---|---|
| device | string | Device identifier |
| stream | string | Stream identifier |
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
| period | integer | No | Minimum interval between two frames sent to this client, in milliseconds |
| token | string | No | Authentication token |
Response
- HTTP 101 Switching Protocols
- WebSocket connection established
- Binary messages containing stream data
Get Poll Interval
Retrieve the current server poll interval.
Endpoint
GET /config/pollQuery parameters
| Name | Type | Required | Description |
|---|---|---|---|
| token | string | No | Authentication token |
Response
200 OK- Body: integer value (milliseconds)
Set Poll Interval
Update the server poll interval.
Endpoint
POST /config/pollQuery parameters
| Name | Type | Required | Description |
|---|---|---|---|
| token | string | No | Authentication token |
Request body
- Plain text integer representing the poll interval in milliseconds
Response
200 OK- Body: updated integer value (milliseconds)
Stop Server
Request a graceful shutdown of the Nyx Stream server.
Endpoint
GET /stopQuery parameters
| Name | Type | Required | Description |
|---|---|---|---|
| token | string | No | Authentication token |
Response
200 OK- Body:
OK
Error Responses
| Status | Description |
|---|---|
| 400 | Invalid request |
| 403 | Unauthorized (invalid or missing token) |
| 405 | Method not allowed |