oscarmlage oscarmlage

Mattermost and Matterbridge

Written by oscarmlage on

When you are a kind of old school, modern times means a bit of pain in some way. Your soul is mostly seeking inner peace but on the other hand, as someone that works with technology, you wouldn't stay freeze.

And sometimes the thing is the other way around, it feels that the old-school-world you're living with is good but not as great as it should and you need to move a bit forward yourself to - wrongly - have a feeling of progress.

As i've said many times, we're using irc as communication tool for a project. It perfectly fits our needs but if I'd asked to compare with some other tools I would say that there are a couple of holes that can't easily be covered:

About first point - sharing graphical stuff - well, you can use imgur or some other similar tools and paste the link, that's what we do, but in the end - as good slackers we are - you think it twice if it's worth the effort. I'm not saying that it's bad think it twice but most of times this upload-to-wherever method does not work with me.

Always-on is an implicit feature in most of instant messaging apps nowadays. You enter a channel/group and from now on you will get every single message wrote there. IRC does not work in that way, you have to be connected to be able to read the conversation. When you disconnect your client you can't receive messages. So if you get disconnected, you lose the log and the ability to reply. Even if you're not connected people does not see you around and in the end they don't write to you because you can't read (that's not bad, you can choose when you will attend and when you won't).

Lastly, we have smartphones now, we should be able to reply from anywhere... but mobile connections are not so stable / reliable, in the end it means lots of disconnections here and there, it's not usable.

What can we do? To deal with the disconnections and the always-on stuff we can use something like ssh + tmux + irssi (irc client). That means install an irc client (irssi) in a stable server, access to it over ssh and play a bit with background/foreground modes with a terminal multiplexer (tmux, screen...).

Now we have the almost-perfect cocktail, right?. Well... now you're running it always, you are not losing parts of the conversation, you can even choose when you're ready for interact with the others or away-from-keyboard (afk) and - with some other stuff like the one I've mentioned in my last post - you can also get notifications when people will mention you. So what's wrong?.

The wrong part is that, using the mentioned stuff, you need to be a real old-school 1337 r35p3c73d hax0r to be able to interact if you are not in front of a real computer with a real keyboard. When you get a mention in your smartphone and want to reply, or just want to read the backlog because you're waiting for a haircut, you have to open a mobile ssh client, pray for stability of the connection, enter the host, attach the detached tmux, go to irssi session/window and deal with the keys and shortcuts. That's all.

Here is where mattermost and matterbridge enters to solve our problem.

Mattermost is an Open Source Slack clone, it's a centralized messaging platform that enables secure team collaboration. It's written in Golang and React and runs as a single Linux binary with MySQL or PostgreSQL. To be honest, it's another instant messaging piece of software, but as it's Open Source it has so many free plugins to integrate with almost everything (github, gitlab, docker, ansible, jenkins, jira, nagios, redmine, trello, zabbix...). Of course it has clients for every existing platform nowadays (Linux, Windows, MacOS, iOS and Android).

Matterbridge is a tool that bridges between a growing number of protocols (mattermost, IRC, gitter, xmpp, slack, discord, telegram, rocketchat, steam, twitch, ssh-chat, zulip, whatsapp...).

So, if we are able to put some glue here and some configurations there maybe with a bit of effort we could solve our little problem:

Install a Mattermost server

As slackers, laziness is the strength that moves us so we are going to use docker for both (mattermost and matterbridge) directly in command line (we should prepare our database before, I told you I was old-school so I don't go for a db-container this time):

docker run -d 
    -p 8000:8000 
    -e MM_SERVICESETTINGS_SITEURL="<https://mymattermost.domain.com>" 
    -e MM_SQLSETTINGS_DATASOURCE="mysqluser:mysqlpass@tcp(,utf8&readTimeout=30s&writeTimeout=30s" 
    -v /home/docker/mattermost/config:/mattermost/config:rw 
    -v /home/docker/mattermost/data:/mattermost/data:rw 
    -v /home/docker/mattermost/logs:/mattermost/logs:rw 
    -v /home/docker/mattermost/plugins:/mattermost/plugins:rw 
    -h mattermost01 
    --name mattermost01 
    --restart always 

Once it's installed we need to create the team and the channel that will receive the messages from irc, take a look to the final urls once the channel is done:

Install Matterbridge

For installing matterbridge we should have a configuration file that says to the binary where to connect and what to do with the messages, so first of all we will create our matterbridge.toml file:





Attending to this file, matterbridge will try to:

So, it's time to run the bridge:

docker run -d 
    -v /home/docker/matterbridge/matterbridge.toml:/matterbridge.toml 
    -h matterbridge01 
    --name matterbridge01 
    --restart always 

And there it goes, if there are no errors we should be able to receive IRC messages in our mattermost channel. Even we can send messages to the IRC from our mattermost client (web, macos, ios, android...) and scroll back without any kind of problems.

Dunno if it's black magic but for me - now that I have a seriously active project running over IRC - it will mean a really nice improvement.