How to setup a WebRTC gateway using matrix on debian
What is WebRTC ?
As the name says, WebRTC is a W3C API for RealTime Communication thought the Web.
Protocol is not new and not widely supported, however there is no doubt it will the standard in near future
since many web platform are supporting it on their latest release.
HTML5Test will give a brief overview of supported browsers :
Most of Open Source browser are supported : Mozilla, Chromium.
Note that Android OS is providing API since version 5.
On the products side there a couple of TV are supporting it maybe more of them.
I wont go much in details but what you have to remember is that you need a server to establish client relationship and make them talk directly using UDP streams.
For the curious ones check https://en.wikipedia.org/wiki/WebRTC
How to install matrix on Debian
Upstream is providing experimental deb packages for Debian and Ubuntu.
It should work on any PC, but I used one of my favorite OSHW device , the MinnowBoard max.
For the record I installed 32bit version of jessie :
( http://cdimage.debian.org/debian-cd/8.2.0/i386/iso-cd/debian-8.2.0-i386-netinst.iso )
Once system booted you can add extra sources.
cat /etc/os-release
apt-get install wget sudo screen
# adapt if needed
release=trusty
release=jessie
grep -i $release /etc/os-release || exit
cat<<EOF | sudo tee "/etc/apt/sources.list.d/matrix_org.list"
deb http://matrix.org/packages/debian/ ${release} main
deb-src http://matrix.org/packages/debian/ ${release} main
EOF
wget -O- http://matrix.org/packages/debian/repo-key.asc | sudo apt-key add /dev/stdin
sudo apt-get update
sudo apt-get install matrix-synapse
Dependencies will be pulled from
The following extra packages will be installed:
libsodium13 libxmlsec1 libxmlsec1-openssl python-bcrypt python-blist
python-cffi python-characteristic python-cryptography python-daemonize
python-decorator python-dns python-enum34 python-formencode
python-frozendict python-idna python-ipaddress python-mako python-markupsafe
python-memcache python-nacl python-openid python-openssl python-paste
python-ply python-pyasn1 python-pyasn1-modules python-pycparser
python-pydenticon python-pysaml2 python-scgi python-service-identity
python-simplejson python-syutil python-tempita python-twisted
python-twisted-bin python-twisted-conch python-twisted-core
python-twisted-lore python-twisted-mail python-twisted-names
python-twisted-news python-twisted-runner python-twisted-web
python-twisted-words python-ujson python-yaml xmlsec1
Suggested packages:
python-dev python-cryptography-doc python-cryptography-vectors
python-enum34-doc python-egenix-mxdatetime python-beaker python-mako-doc
memcached python-nacl-doc python-openssl-doc python-openssl-dbg
python-pastedeploy python-pastescript python-pastewebkit libjs-mochikit
libapache2-mod-wsgi libapache2-mod-python libapache2-mod-scgi python-pgsql
python-ply-doc python-repoze.who python-twisted-bin-dbg python-tk python-qt3
python-wxgtk3.0 python-twisted-runner-dbg
The following NEW packages will be installed:
libsodium13 libxmlsec1 libxmlsec1-openssl matrix-synapse python-bcrypt
python-blist python-cffi python-characteristic python-cryptography
python-daemonize python-decorator python-dns python-enum34 python-formencode
python-frozendict python-idna python-ipaddress python-mako python-markupsafe
python-memcache python-nacl python-openid python-paste python-ply
python-pyasn1 python-pyasn1-modules python-pycparser python-pydenticon
python-pysaml2 python-scgi python-service-identity python-simplejson
python-syutil python-tempita python-twisted python-twisted-conch
python-twisted-lore python-twisted-mail python-twisted-names
python-twisted-news python-twisted-runner python-twisted-words python-ujson
python-yaml xmlsec1
The following packages will be upgraded:
python-openssl python-twisted-bin python-twisted-core python-twisted-web
4 upgraded, 45 newly installed, 0 to remove and 74 not upgraded.
Need to get 4 584 kB of archives.
After this operation, 20,4 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Configuring matrix
Once the packages are downloaded a few configuration steps are needed.
1st select a name, if connected to the Internet I will suggest to use your domain name,
(if no DNS record you can use a dynamic DNS service and configure it using ddclient, for noip.com use dyndns2 protocol).
sudo apt-get install matrix-synapse
┌───────────────────────────────────────────────────────────┤ Configuring matrix-synapse ├────────────────────────────────────────────────────────────┐
│ The name that this homeserver will appear as, to clients and other servers via federation. This name should match the SRV record published in DNS. │
│ Name of the server │
│ pub.no-ip.org______________________________________________________________________________________________________________________________________ │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Some minor fixes are needed, and about to be reviewed upstream ( https://github.com/matrix-org/synapse/issues/390 ) .
sudo apt-get install matrix-synapse-angular-client
cp -av /etc/matrix-synapse/conf.d/webclient.yaml /etc/matrix-synapse/conf.d/webclient.yaml.orig
sudo sed -e 's|,$||g' -i /etc/matrix-synapse/conf.d/webclient.yaml
sudo cp -av /etc/init.d/matrix-synapse /etc/init.d/matrix-synapse.orig
sudo sed -e 's|chown $USER:nogroup $PIDFILE.*|chown $USER:nogroup $PIDFILE /var/lib/$NAME/media|g' -i /etc/init.d/matrix-synapse
diff -u /etc/init.d/matrix-synapse.orig /etc/init.d/matrix-synapse
sudo cp -av /etc/matrix-synapse/homeserver.yaml /etc/matrix-synapse/homeserver.yaml.orig
sudo sed -i 's|enable_registration: False|enable_registration: True|g' -i /etc/matrix-synapse/homeserver.yaml
rm -f /etc/matrix-synapse/conf.d/*.orig /etc/matrix-synapse/conf.d/*~
sudo /etc/init.d/matrix-synapse restart
# if it work you can check server is listening on defaut ports 8008 (http) and 8448 (https)
root@pub:/home/user# lsof | grep matrix-synapse | grep :
python 1277 matrix-synapse 5u IPv4 16304 0t0 TCP *:8448 (LISTEN)
python 1277 matrix-synapse 6u IPv4 16305 0t0 TCP *:8008 (LISTEN)
python 1277 1278 matrix-synapse 5u IPv4 16304 0t0 TCP *:8448 (LISTEN)
python 1277 1278 matrix-synapse 6u IPv4 16305 0t0 TCP *:8008 (LISTEN)
# On trouble check for logs at :
cat /var/log//matrix-synapse/homeserver.log
Create users
Either you configure ddclient to have a DNS record or just use with IP (ifconfig will tell),
for the rest of chapter I will use http://pub.no-ip.org:8008/ as example.
So let’s open location, front page will redirect to “_matrix/client/” page then press [Create account] link at bottom of page and fill the form :
- email : none
- [ ] : Use this account when people search for my email address on Matrix
- Name : admin password admin
- Home Server: http://pub.no-ip.org/
- Identity Server: (none)
- [Sign up]
Congratulation you took the pill of the right color, so now you can just press “[log out]“.
You can create an other one , let’s call it “guest” this is the same procedure from the “/_matrix/client/#/register” page
You can allow new users to be created or disable registration through the previous configuration file.
Log in an meet peers
First I will introduce to rooms, because I feel it’s easier since they have fixed name.
Log in as “admin” user and then press “[create room]” button, let’s call it “public”
- [x] public room
- #public:pub.no-ip.org
Then, log in as other user, at bottom of screen you’ll see the newly created room “#public:pub.no-ip.org” , just press it.
Your browser URL should be in this form : http://pub.no-ip.org:8008/_matrix/client/#/room/#public:pub.no-ip.org
You can share this URL to your contacts, the same way you’ll share an XMPP, IRC or Jitsi room name ( http://meet.jit.si/ ).
As the room is set public it will be public to all accounts, so if needed you’d better invite users from private room.
Private conversations
From the room name of the main page you can select one peer by clicking on its icon and “start chat” button.
then a new room appear of two contacts and if you look at top right side there is 3 icons :
- Microphone : for VOIP call
- Camera : for Audio and Webcam communication
- Gear : for debug and extra option will be ignored for now
Not you can contact your peer by using directly its user name ( Start chat : @guest:pub.no-ip.org )
Assuming your browser is supported and hardware setup correctly wired,
you should be able to initiate a Video call by just press camera icon on right confirm “allow camera” popup.
Download x86 image for EFI32
Download (debian-8_0_2-i386-efi-matrix-20151126rzr.qcow2) from http://opensource.eurogiciel.fr/home/pcoval/pub/file/, and dump it to storage (ie: USB) using
sudo qemu-img convert *.qcow2 /dev/sdX
It has been tested on minnowboard max (reflashed w/ MinnowBoard.MAX_.I32.083.R01.zip).
But could also work on Fish River Island2 too ( FRI - eLinux.org ) ..
Conclusion and going on
This is brief practical introduction to matrix,
today in a couple of hours we set up a standalone WebRTC gateway from scratch.
This worth to be considered as an alternative to closed software or infrastructures,
since it can made it run on cheap single board computers.
(I tested it on Minnowboard max, but also rebuilt it for ARM archi : Odroid C1 and Raspberry pi2).
Keep in mind there is lot more to discover in this project such as federation, persistence or end-to-end encryption for privacy concern
which means a lot in the IoT perspective.
Source: https://dockr.eurogiciel.fr/blogs/embedded/author/pcl/
Keywords: webrtc, matrix, debian, minnowmax, x86, arm, communication, privacy
How to setup a WebRTC gateway using matrix on minnowmax