## MatrixSynapse

## Chat Server (Matrix Synapse)

### What is Matrix?

Matrix is an open standard for interoperable, decentralized, real-time communication over IP. Synapse is the reference implementation of a Matrix server. It can be used to setup instant messaging on FreedomBox to host large chat rooms, end-to-end encrypted communication and audio/video calls. Matrix Synapse is a federated application where chat rooms can exist on any server and users from any server in the federated network can join them. Learn more about Matrix.

Available since: version 0.14.0

### How to access your Matrix Synapse server?

We recommend the Riot client to access the Matrix Synapse server. You can download Riot for desktops. Mobile applications for Android and iOS are available from their respective app stores.

### Setting up Matrix Synapse on your FreedomBox

To enable Matrix, first navigate to the Chat Server (Matrix Synapse) page and install it. Matrix needs a valid domain name to be configured. After installation, you will be asked to configure it. You will be able to select a domain from a drop down menu of available domains. Domains are configured using System -> Configure page. After configuring a domain, you will see that the service is running. The service will be accessible on the configured FreedomBox domain. All the registered users will have their Matrix IDs as `@username:domain`. Currently, you will not be able to change the domain once is it configured.

### Federating with other Matrix instances

You will be able to interact with any other person running another Matrix instance. This is done by simply starting a conversation with them using their matrix ID which is of the format `@their-username:their-domain`. You can also join rooms which are in another server and have audio/video calls with contacts on other server.

### Memory usage

The Synapse reference server implemented in Python is known to be quite RAM hungry, especially when loading large rooms with thousands of members like #matrix:matrix.org. It is recommended to avoid joining such rooms if your FreedomBox device only has 1 GiB RAM or less. Rooms with up to a hundred members should be safe to join. The Matrix team is working on a new implementation of the Matrix server written in Go called Dendrite which might perform better in low-memory environments.

Some large public rooms in the Matrix network are also available as IRC channels (e.g. #freedombox:matrix.org is also available as #freedombox on irc.debian.org). It is better to use IRC instead of Matrix for such large rooms. You can join the IRC channels using Quassel.

### Advanced usage

1. If you wish to create a large number of users on your Matrix Synapse server, use the following commands on a remote shell as root user:

   -     cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1 | sed "s+^+registration_shared_secret: +" > /etc/matrix-synapse/conf.d/registration_shared_secret.yaml
         chmod 600 /etc/matrix-synapse/conf.d/registration_shared_secret.yaml
         chown matrix-synapse:nogroup /etc/matrix-synapse/conf.d/registration_shared_secret.yaml
         systemctl restart matrix-synapse
         register_new_matrix_user -c /etc/matrix-synapse/conf.d/registration_shared_secret.yaml

2. If you wish to see the list of users registered in Matrix Synapse, the following as root user:

   -     apt install sqlite3
         echo 'select name from users' | sqlite3 /var/lib/matrix-synapse/homeserver.db

3. If you wish to create a community in Matrix Synapse, a Matrix user with server admin privileges is needed. In order to grant such privileges to `username` run the following commands as root user:

   -     sudo apt install sqlite3
         echo "UPDATE users SET admin=1 WHERE name='@username:domainname'" | sudo sqlite3 /var/lib/matrix-synapse/homeserver.db