Configuration
To set up ObjectBox Sync Server to your needs, there are various configuration options, which are presented on this page.
There are two approaches to configure ObjectBox Sync Server:
command line parameters (CLI): simple/quick approach for most settings (limitations apply)
configuration file (JSON): recommended for complex settings and required for sync filters and clusters
Note that both approaches can be combined.
Configuration via command line (CLI)
Running the Sync Server from the command line is a simple way to get started. It's a good idea to look at the output of running sync-server --help (your output may vary, e.g. when using a newer version of the Sync Server).
More details about the options can be found in the section on the configuration file. Just note that the naming convention is different (e.g. dbMaxSize instead of db-max-size), but both refer to the same underlying option.
Configuration file
In the long run, you should store the configuration in a JSON file. This is the preferred choice if the options are getting more complex (e.g. you can check in the configuration file into version control). Also, it's the only way to configure a cluster.
By default, the configuration file is read from sync-server-config.json in the current working directory. To use a different location, supply it via the --conf <path-to-config> option.
Some options have a default value, so if you are OK with the default, there is no need to specify it.
Example file:
{
"dbDirectory": "objectbox",
"dbMaxSize": "100G",
"modelFile": "",
"bind": "ws://0.0.0.0:9999",
"adminBind": "http://127.0.0.1:9980",
"adminThreads": 4,
"certificatePath": "",
"auth": {
"sharedSecret": "",
"google": {
"clientIds": []
}
}
}Primary options
dbDirectorydirectory where the database is stored (default: "objectbox").dbMaxSizedatabase size limit; use a number with a unit, e.g. 256G (default: 100G)Kfor kibibytes, i.e. 1024 bytesMfor mebibytes, i.e. 1024 kibibytesGfor gibibytes, i.e. 1024 mebibytesTfor tebibytes, i.e. 1024 gibibytes
modelFileschema (model) file to create the database with or to use for a schema updatebindSync server will bind on this URL (scheme, host and port). It should look likews://hostname:port, for examplews://127.0.0.1:9000. You can also bind to a specific IP address on the server machine by providing the exact address, as given byifconfigorip addr, e.g.ws://192.168.0.125:9999.adminBindHTTP server (admin/web UI) will bind on this URL (schema, host and port combination).
Developer and debug options
unsecuredNoAuthenticationallows connections without any authentication. Note: this is unsecure and should only be used to simplify test setups.debugLogenable debug logs withtrue
Authentication options
auth.jwtJWT is the primary method for authentication. See the JWT authentication page for details.
Sync filter expressions
syncFiltersthis JSON object contains all filter expressions. Each filter has the type as key and a string value as the expression. Details are in the sync filters page.
Advanced options
adminThreadsnumber of threads the HTTP server uses (default: 4). A low number is typically enough as it's for admins only. You may need to increase if running in some cloud setups that keep the connections active (e.g. Kubernetes).auth.sharedSecretif not empty, enables the shared secret authentication with the given keyauth.google.clientIdsa list of GoogleAuth client IDs (strings)auth.obxAdminset it totrueto enable ObjectBox Admin users for sync authentication (e.g. for small deployments and tests)certificatePathSupply a SSL certificate directory to enable SSL. This directory must contain the filescert.pemandkey.pem.workerssets the number of concurrent workers for the main task pool (default is hardware dependent, e.g. 3 times the number of CPU cores).
Clusters
To set up a cluster, please refer to the cluster page for specific configuration options.
Authentication
Authentication settings for clients are required; the Sync Server won't start without them. If you try, it should look something like this:
$ ./sync-server --model=objectbox-model.json
...
001-13:05:07.3526 [ERROR] [SySvAp] Runtime error: Authenticator must be set before starting
001-13:05:07.4524 [INFO ] [SvSync] Stopped (port 0)
Authenticator must be set before startingFor production usage, please refer to the JWT authentication page on how to authenticate your clients.
Other authentication methods are mentioned above in the configuration overview, i.e. Google Authentication with client IDs, shared secret, Admin users. Typically, we recommend using JWT, but there may be occasions where you need to use other authentication methods. Let the ObjectBox team know about your use case and requirements. E.g. it is possible to define multiple authenticators.
Combining CLI and file configuration
You can mix both approaches, i.e. have a configuration file and use command line (CLI) options. In this case, CLI options have precedence over the options in the JSON config file. Thus, you can store your base configuration in a file, and override or add settings by providing command line arguments.
Last updated
Was this helpful?