top of page
Search
  • Writer's pictureFrederick Dopfel

Building a Chat Server

I have always been interested in productivity tools to help build, maintain, and strengthen my social and professional network, and during one of my explorations in the space. Frankly, I believe that social networks as a communication medium should be protocols, not platforms, and so I have experimented with a number of open source and blockchain-based social networks and chat apps. While browsing the internet, I found an interesting chat app: rocket.chat, which is free, open source, and can be self-hosted. After discovering that it is small enough to be run on a Raspberry Pi, I knew I had to build one myself.


Usually I buy 2GB variants of the Raspberry Pi 4, but in this case, I decided to buy the 4GB variety, since others who have experimented with Rocket chat claim that the extra memory has some real-world performance implications for simultaneous connections. Although my current plans are to use this server only for my family, I don't know if I will be expanding the user base in the future, so I decided it would be best to add some extra capacity.



Rocket Chat by default looks and feels a lot like slack, but the ability to have super-fine grained permissions controls, local unlimited message storage, and highly-customizable user interface design makes it an attractive option for tinkerers or people who want to build their own white-label private chat system. In my case, I plan to leave most options at their defaults for now, and instead focus on getting the software up and running.


Installation was actually pretty simple. After flashing a SD card with Raspbian (now called Raspberry Pi OS) and physically setting up the Raspberry Pi, I opened up terminal and installed snap, a special library for installing software.


sudo apt-get install snapd

Once snap was installed, I can use the automated install system to get set up


sudo snap install rocketchat-server

And just like that, my chat server was up and running. A few configuration changes could even boot the server on startup. Easy, right? Well......



Just because the chat server is up and running, doesn't mean that clients can connect to it. The server could be accessed only on the local network, and this was obviously not ideal.


I opened up and forwarded the relevant ports on my router to the chat server, and used my existing DDNS address to connect to the server. For those that don't know, DDNS is a system where an existing address (for example freddydopfel.com) will always redirect to a specific public IP address. This is especially important for devices on residential internet connections, where Internet Service Providers regularly change the public IP address. In my case, I already had a DDNS set up with Duck DNS for my personal Raspberry Pi VPN, so I could recycle that existing domain to make installation easier.


With the DDNS and port forwarding, devices from outside the network could easily connect to my chat server with an easy-to-remember URL. Testing on my Android phone and Macbook worked great.


However, a problem occurred when I started onboarding the rest of my family. Some of my parent's devices were unable to connect to my server. Rather quickly, I noticed a pattern: iOS devices couldn't connect, but all other devices could. It turns out that iOS has some rules about requiring all chat connections to be encrypted, and so the app wasn't happy going through a simple DDNS service.


Fortunately, other enthusiasts had encountered and fixed these problems before me. The recommended solution is to use software called ngrok to create secure encrypted tunnels to the Raspberry Pi. In theory, this system is even easier to use than a DDNS because it doesn't require any router configuration. However, the software generates a new url every time the Raspberry Pi boots. This is fine for testing, but not ideal as a long-term solution, where power outages may occur, and I would then have to reconfigure my parents' devices. Fortunately, ngrok offers a paid plan with a custom url at a reasonable price. I don't like paying a monthly fee for a chat service I am hosting on my own hardware, but I suppose that for the sake of this project, it is worth it.


Overall, my family is enjoying using Rocket Chat, and I am excited to build more on top of this platform. Some ideas that we have already decided we want to implement include:


Future projects on top of Rocket Chat include:

Adding video chat functionality

Integration with HomeAssistant for home alerts and text control

Setting up an account for my family's cat. My parents want to find a way to talk to the cat, maybe through a soundboard? (https://www.youtube.com/watch?v=KYysVTJqFto)

276 views0 comments

Recent Posts

See All
bottom of page