nabto_client_connection_set_options()
DESCRIPTION
Set options with a json encoded document.
There are two ways to setup connection options. Either use the unified json interface which has all possible options, or use the individual set functions for the most commonly used connection options.
This functions can be used to set connection parameters in bulk or as indidual parameters.
Connection options.
- PrivateKey: string pem encoded EC private key
- ProductId: string
- DeviceId: string
- ServerUrl: string
- ServerKey: string
- ServerJwtToken: string
- ServerConnectToken: string
- AppName: string
- AppVersion: string
Control the keep alive settings for the connection between the client and the device.
- KeepAliveInterval: unsigned integer in milliseconds, default 30000
- KeepAliveRetryInterval: unsigned integer in milliseconds, default 2000
- KeepAliveMaxRetries: unsigned integer default 15
Set the timeout for getting the first DTLS packet back from the device. This is used to make a connection attempt fail faster if a route to the device is believed to be open, when in fact it is not. Eg. if the device lost its connection to the Nabto Server, but the server has yet to detect the disconnect.
- DtlsHelloTimeout: unsigned integer in milliseconds, default 10000
Set the timeout for a connect attempt. This is a upper limit on the time it takes for nabto_client_connection_connect to resolve.
- ConnectTimeout: unsigned integner in milliseconds, default 120000
Control which connections features to use.
Set local to enable/disable local connections
- Local: (true|false)
Enable/disable connections mediated through a cloud server.
- Remote: (true|false)
Enable/disable udp holepunching on remote connections.
- Rendezvous: (true|false)
Use pre 5.2 local discovery. Before 5.2 devices are located by doing an mDNS scan for all the devices. After 5.2 including 5.2, devices are located by a device specific mDNS subtype. Set this option to true to use the pre 5.2 way of locating devices.
- ScanLocalConnect: (true|false)
Example - force local connections:
std::string options = R"(
{
"Remote": false
}
)";
nabto_client_connection_set_options(connection, options.c_str());
Example - setup a connection:
std::string options = R"(
{
"ProductId": "pr-12345678",
"DeviceId": "de-12345678",
"ServerUrl": "https://pr-12345678.clients.nabto.net",
"ServerKey": "sk-12345678123456781234567812345678"
}
)";
nabto_client_connection_set_options(connection, options.c_str());
This function can only be invoked before the connection establishment is started.
DECLARATION
NABTO_CLIENT_DECL_PREFIX NabtoClientError NABTO_CLIENT_API
nabto_client_connection_set_options(NabtoClientConnection* connection, const char* json)
PARAMETERS
connection:
- [in] The connection
json:
- [in] Options formatted as json
RETURNS
NABTO_CLIENT_EC_OK
: if the json document is parsed and understood.NABTO_CLIENT_EC_INVALID_ARGUMENT
: if the json is not understood. See error log for more details.