Defaults
Msgpack serialization
Messages between the device and NervesHub are JSON by default. Msgpack encodes the same messages in fewer bytes and uses less memory on the device while doing it. Use it on metered or low bandwidth connections.Requirements
nerves_hub_link2.13.0 or later.- NervesHub 2.5.0 or later, on every node a device can reach.
Enable it
Add the optionalmsgpax dependency:
Limits
- If
msgpaxis missing, or:serializeris a value the library does not know, the device logs an error and connects with JSON. - The two formats do not put identical values on the wire. Msgpack carries timestamps, such as the one in a health report, as its own extension type. JSON sends an ISO 8601 string.
TLS 1.3 and session resumption
The device offers TLS 1.2 on the WebSocket by default. When the server supports TLS 1.3, the device can offer that too and keep TLS 1.3 session tickets. A reconnection then uses a resumed handshake, which sends no certificates and verifies none. That saves bytes and round trips on slow or metered connections such as LTE-M.Requirements
- NervesHub 2.5.0 or later, which is the first version that issues session tickets.
- TLS 1.3 turned on for the instance’s device endpoint. It is off by default. See Feature prerequisites.
- Devices running OTP 25.1 or later.
Enable it
:ssl refuses session_tickets unless :"tlsv1.3" is one of the :versions. Keep :"tlsv1.2" in the list so that a device reaching a server without TLS 1.3 still connects.
Devices that authenticate with a certificate (NervesKey, TPM, or a local certificate and key) and devices that authenticate with a shared secret can both resume.
How tickets are kept
- Erlang’s
sslapplication holds tickets in memory. They survive a socket reconnect but not a reboot. The first connection after boot is always a full handshake. - A ticket is matched on the server name. That is the host the device connects to, or
:sniif you configured one. - Two
sslapplication variables bound the ticket store. They default to two hours and 1000 tickets. A device that talks to one server can use a smaller store:
Firmware downloads
The firmware downloader leaves the TLS version toMint, which already offers TLS 1.3. It can resume handshakes too. This helps when firmware is downloaded in parts or a download is retried:
The server side
If you host NervesHub, these environment variables on the device endpoint control TLS 1.3:
A resumed handshake skips certificate verification in the TLS layer. NervesHub still checks the certificate carried in the ticket against its database when the socket connects.
Compression
The device offers per-message deflate on the WebSocket (nerves_hub_link 2.8.0 or later). NervesHub negotiates it by default. A device that offers the extension to a server that does not answer with it sends uncompressed frames, so neither side depends on the other.
To stop the device offering it:
CA certificates
The device verifies the NervesHub server certificate. It picks the CA certificates to verify against in this order:cacertsin the:ssloption, if you set it.- The module named in
:ca_store, if you set one. - CAStore, if it is a dependency of your project.
- The CA certificates installed on the device.
ca_certs/0 function that returns a list of DER encoded certificates:
HTTP proxy
Devices that reach NervesHub through an HTTP proxy can configure one for the WebSocket connection and for the firmware downloader. This needsnerves_hub_link 2.12.0 or later.
Mint.HTTP.connect/4 as :proxy, so any proxy form Mint accepts works.
http_opts (under :socket) and :downloader_http_opts forward any other option Mint.HTTP.connect/4 accepts, such as :proxy_headers or :hostname. They merge on top of the SSL configuration instead of replacing it, so you can combine them:
Check that it works
After you flash firmware with a changed transport setting, confirm on the device that it still connects:the :msgpack serializer needs the :msgpax dependency, using JSON insteadunknown serializer ..., using JSON instead

