Sync Server
How to use standalone ObjectBox Sync Server and set it up as a data synchronization target for clients.
Last updated
Was this helpful?
How to use standalone ObjectBox Sync Server and set it up as a data synchronization target for clients.
Last updated
Was this helpful?
The ObjectBox Sync Server is the centerpiece of ObjectBox Sync. It lets ObjectBox Sync clients connect to exchange data both ways (data synchronization).
ObjectBox Sync Server is a very efficient making it usable on a wide range of devices. By itself, it needs only a few MB RAM and disk space. It even runs on small devices like a Raspberry Pi and mobile phones. Nevertheless, it seamlessly scales to the cloud serving millions of clients when set up as a cluster.
To test the Sync Server with your data, ObjectBox offers a free trial. It comes as a publicly available Docker image, which you can pull from :
For a fully operational Sync Server, you need to start it with a data model file (see below). But to quickly verify that it is starting up fine, you can use the following command to make it print its version and exit:
OK, now let's see how get the data model file...
To start the server, you need to pass your data model, which describes the structure of your data. It is JSON file generated by one of the and is required to initialize the ObjectBox Server database.
If you did not define a data model yet, then now is the time to do so. Basically, you need to start this on the client side by defining your data types in the programming language of your choice. Then, the ObjectBox tooling will generate the data model file. This is a standard process even for the non-sync ObjectBox database. So it's a good idea to look at the and especially at the that tag your data classes (e.g. @Entity
). Data types that shall be synced via ObjectBox Sync also need to be tagged accordingly (e.g. @Sync
). This is .
Keep your data model file safe and secure. It contains the schema of your data model along with unique IDs which cannot be restored. If you lose it, you will lose access to your data and synchronization. Thus, always check the JSON file into your version control system, e.g. git.
Now the server should be running and accessible:
ObjectBox Sync on all interfaces, port 9999: Use this information (using a reachable IP or host name) to setup Sync clients
Once consented, the Sync Trial page displays trial status, which should look like this:
You have plenty of time to explore ObjectBox Sync. You can always restart the trial:
If the "trial version" expired, it is a sign that the software is out of date. Renew the Docker image by pulling (docker pull objectboxio/sync-server-trial
).
If the dataset expired, create a new dataset. Start with a fresh database, e.g. by using another mount for the data folder. Alternatively, delete the database folder, which is typically called "objectbox" and contains a data.mdb file. Making a backup of the folder first is recommended.
The ObjectBox Sync Server Admin UI runs as part of the sync-server executable and allows you to:
view the data and download it in JSON format,
view current schema information and previous schema versions,
view runtime information, like version number, database size, network interfaces, ...
manage Admin UI user credentials
The "Sync Statistics" item of the menu on the left contains numerous charts with server runtime information. This can be valuable in multiple ways, e.g. during development and in production, you can verify your applications connect to the server (show up in "Connects" and "Connected clients") and synchronize data (see "Client applied *"). Also, there are multiple charts showing errors - watch for those when trying to figure out issues with your clients.
In the main menu, you will find "Status" to open a page with some useful information. While the following layout is still not final, it will give you a first impression of what to expect:
The "Debug logging" switch on the status page enables a very detailed logging (to standard output).
By default only logs with "info" level and above are enabled, which are relatively rare. For example, there's nothing logged about standard interactions with clients. That might be overwhelming with a few hundred clients already. Info logs should never "spam" you, no matter how many clients are connected.
Let's look at a typical log during startup:
As you can see, logging is structured into columns:
Thread: the first three digits are the number of the thread that logged the text message
Time: UTC time using 24 hours format, including 1/10,000 second precision (1/10 milliseconds)
Level: One of the log levels (listed with increasing severity):
DEBUG: extensive logs to help diagnosing a specific behavior. Debug logs are only enabled if the DebugLog feature flag is on (usually the Sync Server ships such feature). You also need to make sure the Debug logging switch is enabled on Admin UI (see the screenshot above).
INFO: "important" information
WARN: something unusual has happened that you might want to check.
ERROR: reserved for special error occasions ("something bad happened") that typically require some action. It might be that the machine is running out of resources (RAM, disk space etc) or an unexpected situation was encountered. When in doubt, reach out to the ObjectBox team to clarify what's going on.
Tag (optional): Most logs include a tag identifying the internal component
Message: the actual log text
After startup, you typically won't see anymore logs by default. In contrast to "info" and above, "debug" level logs give you extensive information including client connects and message interactions with clients.
To give you a feel what debug logs are like have a look at the following example. It shows a new client connecting, logging in and sending data:
The model JSON is used to initialize the data model for sync (and also the database schema). Later, when your data model has evolved, you will want to update model at server. You have two options to supply a newer version:
Starting the server with an updated model file.
Upload the model file through the Admin web UI.
And if you run into issues, please let the ObjectBox team know; we're happy to help.
Thank you!
Alternatively, you could keep data in a separate docker volume. This example shows how to create the volume for the first time and then how to use it to start the Sync Server container (note: the difference to the previous example is in --mount
and --user
arguments).
Once the image is pulled, you can [run](Once the image is pulled, you can the container. The following example starts Sync Server using the current directory as the data folder and exposes the sync-server on localhost:9999 and admin web UI on . Ensure to have the file objectbox-model.json in the current directory on your host (it's mapped to /data inside the container):
Admin web UI on localhost, port 9980: Have a look at in your web browser.
If you run into any problems, please check the .
Once the ObjectBox Sync Server is started, open the Admin web UI at and you should be taken to the page. It shows the conditions for the trial version, e.g. that you have a testing period of 30 days per dataset. After you consent, you are forwarded to log in with your ObjectBox user account. If you don't have an account yet, you can register using email/password, a GitHub or a Google account.
The setup options for ObjectBox Sync Server are detailed on the page. In summary, you can use command line options (e.g. run sync-server --help
for a quick overview), or use a JSON configuration file for more complex setups. Again, please check the page for details.
For details, please refer to the section.
We're looking forward to your feedback to prioritize the most requested features. Please fill in this to tell us what you think.
When using Docker on Windows, this guide expects you to use . Check the if you don't have it installed yet.
To follow the best practices and achieve optimal performance, as described by and , use a data volume for the database directory instead of binding to a local directory. Follow Using Docker volumes for database files to do that.