Protocol: nabto.system/1

The nabto.system/1 protocol provides service discovery for a Cambridge device. It allows clients to query which services and protocols are available before opening additional datachannels.

Opening a Datachannel

To use the system protocol, create a WebRTC datachannel with the protocol "nabto.system/1". The datachannel label can be picked arbitrarily:

const channel = pc.createDataChannel("system", {
    protocol: "nabto.system/1",
});

All messages on this channel use the JSON-RPC 2.0 format.

system.listServices

Lists all services available on the device, along with the protocols each service supports.

Request

{
  "jsonrpc": "2.0",
  "method": "system.listServices",
  "params": {},
  "id": "1234"
}

Response

{
  "jsonrpc": "2.0",
  "result": {
    "services": [
      { "name": "system", "protocols": ["nabto.system/1"] },
      { "name": "http", "protocols": ["nabto.http/1"] },
      { "name": "rtsp", "protocols": ["nabto.rtsp/1"] }
    ]
  },
  "id": "1234"
}

Each entry in the services array contains:

FieldTypeDescription
namestringThe service name, used as the datachannel label when opening a channel to this service
protocolsstring[]List of supported protocol identifiers for this service

Error Handling

All Cambridge protocols use standard JSON-RPC 2.0 error responses:

{
  "jsonrpc": "2.0",
  "error": {
    "code": -32600,
    "message": "Invalid Request"
  },
  "id": "1234"
}

Cambridge uses the server-specific error code range -32000 to -32099 for application errors. Standard JSON-RPC errors (parse errors, invalid requests, method not found) use the standard range as defined by the specification.

Unsupported Protocol

If a client opens a datachannel with a protocol that Cambridge does not support, the device sends a JSON-RPC error with "id": null and then closes the datachannel.