If you are running a standard Nerves device, the
nerves_hub_link library handles all WebSocket protocol details automatically. This reference is intended for custom client implementations, low-level debugging, or non-Nerves platforms connecting to NervesHub.Connection URI
Establish the WebSocket connection to the following endpoint:devices.nervescloud.com:
Phoenix Channels Message Format
NervesHub uses the Phoenix Channels wire protocol. Every message is a five-element JSON array:
Example — server pushing a firmware update event:
Supported Topics
NervesHub exposes two channel topics over the device WebSocket connection:device
The primary channel for firmware updates, device status, and lifecycle events. All devices must join this topic. Requires
device_api_version in the join payload.console
Provides remote IEx shell and console I/O access. Join this topic to enable the remote interactive Elixir console for a device.
Joining the Device Channel
After the WebSocket connection is established, send aphx_join event on the device topic. Include device_api_version in the payload to declare the protocol version your client supports:
phx_reply event. A successful join response has the following shape:
"error" and the response object will contain a reason string.
Extensions
After joining, a device and the server negotiate extensions — optional capabilities such as health reporting, metrics, geo, logging, the local shell, network identity, and error reports. The device advertises which versions of each extension it supports, and the server replies with the ones enabled on the product that it can speak. A device is only sent messages for extensions that were successfully negotiated, so an older client that does not know about an extension simply never receives its traffic.Joining the Console Channel
To open a remote IEx session, join theconsole topic after the device channel is established:
Reconnection Behaviour
Devices must implement reconnection with exponential backoff. Network interruptions and server-side restarts are expected in production fleet deployments. A recommended backoff strategy:- Start with a 1–2 second initial delay
- Double the delay on each failed attempt
- Cap the maximum delay at 60–120 seconds
- Add random jitter (±20%) to avoid thundering-herd reconnection storms across a large fleet
Heartbeats
Phoenix Channels use a heartbeat mechanism to detect stale connections. The client must send aheartbeat event on the phoenix topic at regular intervals (default: every 30 seconds):
Authentication
Device identity is established at the TLS layer before the WebSocket handshake. NervesHub supports three authentication modes:Device Certificates
X.509 client certificates presented during the mTLS handshake. The recommended approach for production devices.
Shared Secret
A
product_key and product_secret used to derive an HMAC credential. Suitable for development and devices without hardware security modules.NervesKey
ATECC508A or ATECC608A hardware security module stores the private key in tamper-resistant hardware. The private key never leaves the chip, making this the most secure option for production fleets.

