Setting up a local Firefox Sync server

I love Firefox. Aside from the quite awesome levels of cross-platform support, I’m a big fan of the built-in Sync feature. For those concerned about security and privacy, Mozilla provide instructions for setting up your own Sync server, and the good news is that it’s a snap to get a basic server up and running.

For a start, on an Ubuntu 10.04 x86 VirtualBox VM, I followed the “Prerequisites” and “Building the server” sections here:

http://docs.services.mozilla.com/howtos/run-sync.html

My server VM is running with bridged networking on my local network with its own IP address.

 

Upon running the server and attempting to connect from other Firefox clients, I ran into two problems which I don’t believe are documented at the above link.

First, I could not get clients to connect successfully to the server using the handy “Add a Device” Sync feature. To troubleshoot and resolve this, I performed the following steps.

  1. Set up Firefox sync on the relevant client browser.
  2. In the Firefox client, launch the Firefox configuration page by entering about:config in the address bar (more information on this may be found here).
  3. Use the search filter to narrow down the entries relevant to Sync settings.


I noted that the setting named services.sync.serverURL was correctly pointing towards my server. I would have thought that this was sufficient to get Sync working, but apparently not: in my case, the setting named services.sync.clusterURL was pointing to localhost, and this also needed to be set to the server address (i.e. identical to the value set for services.sync.serverURL). Once done, the client could then successfully connect to the Sync server.

Update to the above: This is resolved by modifying the fallback_node property of the Sync server sync.conf file. There is a somewhat misleading reference to this in the official documentation, which says (at the time of writing):

“Warning: If you run behind a server, you need to set up the fallback_node option in the [auth] section accordingly…”

What is actually meant is if the server is serving multiple remote (i.e. non-local) clients, then the server address should be set in the fallback_node property. By default, the property is set to the following in the sync.conf file:

[auth]
backend = services.auth.sql.SQLAuth
sqluri = sqlite:////tmp/test.db
pool_size = 100
pool_recycle = 3600
create_tables = true
fallback_node = http://localhost:5000

If the IP address of my server is 192.168.1.4, then I would modify this to read:

[auth]
backend = services.auth.sql.SQLAuth
sqluri = sqlite:////tmp/test.db
pool_size = 100
pool_recycle = 3600
create_tables = true
fallback_node = http://192.168.1.4:5000

Clients should then connect to the Sync server seamlessly.

 

Second, once my clients were happily syncing up with my server, upon rebooting the server every one of them crapped out with a Sync authentication error. It turns out that the authentication database by default is stored at /tmp, so on reboot of course everything goes kablooey. Again, this is not documented clearly in the setup guide, but it can be resolved by performing the following.

Inspecting the contents of the Sync sync.conf file, the location of the storage and authentication databases can be specified. By default, the locations are defined as follows:

[storage]
backend = syncstorage.storage.sql.SQLStorage
sqluri = sqlite:////tmp/test.db
standard_collections = false
use_quota = true
quota_size = 5120
pool_size = 100
pool_recycle = 3600
reset_on_return = true
display_config = true
create_tables = true

[auth]
backend = services.auth.sql.SQLAuth
sqluri = sqlite:////tmp/test.db
pool_size = 100
pool_recycle = 3600
create_tables = true
fallback_node = http://localhost:5000

 

I changed these to point to a database that will instead be created at /var/sync:

[storage]
backend = syncstorage.storage.sql.SQLStorage
sqluri = sqlite:////var/sync/sync.db
standard_collections = false
use_quota = true
quota_size = 5120
pool_size = 100
pool_recycle = 3600
reset_on_return = true
display_config = true
create_tables = true

[auth]
backend = services.auth.sql.SQLAuth
sqluri = sqlite:////var/sync/sync.db 
pool_size = 100
pool_recycle = 3600
create_tables = true
fallback_node = http://localhost:5000/

 

After reconfiguring all Firefox client Sync connections, authentication then continues to function after the Sync server is rebooted.

Sync also works successfully from Firefox running on the Eee Slider Pad as well, if the first troubleshooting step is performed.

 

See also: http://www.wenks.ch/fabian/mozilla-custom-sync-server/

Advertisements

11 thoughts on “Setting up a local Firefox Sync server

  1. Pingback: Set up Firefox Sync to connect to a PostgreSQL database | Dave Koelmeyer

  2. Pingback: Clear history add-on for Firefox Mobile | Dave Koelmeyer

  3. Klonos

    I got the following error when running make build:

    KeyError: '/tmp/easy_install-Xk7lIG/PasteDeploy-1.5.0'
    
    ----------------------------------------
    Command /root/server-full/bin/python -c "import setuptools;__file__='/root/server-full/build/PasteScript/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-OAEcWz-record/install-record.txt --install-headers /root/server-full/include/site/python2.7 failed with error code 1 in /root/server-full/build/PasteScript
    Storing complete log in /root/.pip/pip.log
    make: *** [build] Error 1
    

    Any ideas what I might be doing wrong?

    PS: this is on Ubuntu 12.04 x64 that has python 2.7 instead of 2.6 by default:

    python --version
    Python 2.7.3
    
    Reply
    1. Derek Cooper

      I had a similar problem and it looked like it was failing to download the pastescript python extension. I found a pastesript package in the apt repositories (using Synaptic) and installed it. When I tried again the compile worked.

      Reply
      1. s

        Well, I have a VPS I attempted to install it on, succeeded up to the point where the sync came up in firefox. It didn’t do anything and attempts to re-connect have failed. I will attempt to re-set it all up using a vm image of ubuntu or debian. I was hoping you had a pre-configued image but it’s no big deal to set one up.

  4. s

    Still can’t seem to get it to work, I followed all instructions, but it appears that the sync doesn’t happen. Not sure what’s going wrong. The server logs are showing a registration completed, a few get and put statements, but no progress takes place. When I check the quota I get “could not retrieve quota information” Not sure what I am doing wrong.

    Reply
    1. s

      It seems to work when using mysql backend. It has something to do with the sqlite backend. My setup managed to create a db file but for some reason that’s where the server dies. It appears that mysql has solved my issue.

      Reply
  5. Pingback: Custom Firefox Sync servers now supported again for Firefox for Android | Dave Koelmeyer

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s