SMP (SimpleX Messaging Protocol) server setup
Short guide on how to install SMP server to be used with SimpleX Chat.SimpleX Chat
This guide has some notes and additions for people who are less experienced with Linux.
If you are setting up a new host machine, I suggest using Ubuntu Server 22.04 LTS. Not only it is well-supported and reliable, but also, SimpleX Chat author (epoberezkin) provides SMP server executable binaries for Ubuntu Server 20.04 LTS and newer (to save you the hassle of having to build them yourself).
Host machine (Ubuntu Server) setup
Open Ports
SimpleX Chat uses port 5223 to communicate with the SMP server. Make sure this port is open and the host machine is reachable on this port from the Internet.Preparation
Update your host's system:sudo apt update sudo apt upgrade sudo rebootInstall micro text editor: (it has familiar Windows-y shortcuts, Ctrl+X/C/V for clipboard, Ctrl+Q to quit, if you prefer any other editor, please ignore this step)
sudo apt install micro
Download and install the SMP server
Download the SMP server binary:wget https://github.com/simplex-chat/simplexmq/releases/download/v3.0.1/smp-server-ubuntu-20_04-x86-64Move the binary to the appropriate directory: (/usr/local/bin is for executables NOT managed by package managers)
mv smp-server-ubuntu-20_04-x86-64 /usr/local/bin/smp-serverMake the binary executable:
chmod +x /usr/local/bin/smp-serverCheck that the executable binary is properly installed:
which smp-servershould return:
/usr/local/bin/smp-server
Initialize the SMP server
If you have a fully-qualified domain name: (for example, smp.mysite.net)smp-server init -l -n smp.mysite.netIf you are using just the IP: (for example, 199.199.199.199)
If you are running behind NAT, use the external IP address.
smp-server init -l --ip 199.199.199.199IMPORTANT: After the SMP server initializes, it will give you a Fingerprint. Copy and save it. (Ctrl+Shift+C to copy from terminal)
Setup guide suggests copying the private CA key (/etc/opt/simplex/ca.key) to another machine and then deleting it from the host machine. I haven't done this.
Create a systemd service
To automate starting the SMP server, create a systemd service:micro /etc/systemd/system/smp-server.serviceThen write the service's definition:
[Unit] Description=SimpleX Messaging Protocol Server After=network.target [Service] Type=simple ExecStart=smp-server start Restart=always RestartSec=3 KillSignal=SIGINT [Install] WantedBy=multi-user.target(Ctrl+S to save, Ctrl+Q to quit)
Since you just added a new service, refresh the system daemon:
sudo systemctl daemon-reloadEnable the new service so it starts when the server is started:
sudo systemctl enable smp-serverStart the new service:
sudo systemctl start smp-serverCheck the status of the running service:
sudo systemctl status smp-server
SMP server address
Now, using the fingerprint and domain name (or IP address) from above, create the full SMP server address. It should look something like:smp://u2dS9sG8nMNURyZwqASV4yROM28Er0luVTx5X1CsMrU=@smp4.simplex.imor
smp://hpq7_4gGJiilmz5Rf-CswuU5kZGkm_zOIooSw6yALRg=@45.33.61.248IMPORTANT: Copy and save this value. (I will refer to it as the "SMP Server Address")
Testing
Do this on your own machine. Or if you don't have a Linux machine, you can do it on the host machine too I guess?Install the SimpleX Chat terminal client (command from the SimpleX Chat site)
curl -o- https://raw.githubusercontent.com/simplex-chat/simplex-chat/master/install.sh | bashIf you don't trust running scripts from the web (and you should not!), download a pre-compiled binary or install SimpleX Chat via official instructions.
Pre-compiled binaries for SimpleX Chat terminal client
SimpleX Chat terminal client installation instructions
Run SimpleX Chat and tell it to use your new SMP Server Address: (using the parameter tells the client to use the server only for this session - see below for permanent change)
simplex-chat -s smp://xxxxxxxx@xxx.xxxxxx.xxxor
simplex-chat -s smp://xxxxxxxx@nnn.nnn.nnn.nnnAnswer the initial questions such as your display name.
Now you are in the Simplex Chat terminal client. Type /help for list of commands.
Create a connection:
/connect
If you get an error:
smp agent error: BROKER {brokerErr = NETWORK}It means your SMP server is not running or is not reachable. Check the connection between your client machine and your host machine. Check that port 5223 is open on the host machine. Log back into the host machine and start / restart the SMP server service (see above).
If everything is OK, you should get a very long invitation link. Copy it from the terminal (Ctrl+Shift+C) and send it to the second client (SimpleX Chat on your phone, for example). Open the link on the second client, which will start the conversation.
If you are able to communicate between the two clients, you're all set!
Using the new SMP server
Now you can use your new SMP Server Address in all of your clients.For terminal client:
/smp_servers smp://xxxxxxxx@xxx.xxxxxx.xxxor
/smp_servers smp://xxxxxxxx@nnn.nnn.nnn.nnnFor mobile clients, open Settings, find an option "SMP servers", toggle "Configure SMP Servers" to on, then enter the SMP Servers Address for all servers you want the client to use.
IMPORTANT: To use the new SMP server, re-establish connections to your contacts once you change SMP server(s) in your client.