How to create your own Chat server like WhatsApp

NC

This article explains How to build your own Chat server like WhatsApp. The operating system used in this article is Ubuntu. To build chat server I use rocket chat. With rocket chat you will have your own chat application without being bothered by ads and completely private.

Install Rocket Chat

To install rocket chat you just need to use a single command as follow:

sudo snap install rocketchat-server

Set Up Rocket Chat

After installing rocket chat, open any web browser and enter the ip address of ubuntu to set it up. In this example the ip address of the ubuntu server is 10.11.32.98. The default port of rocket chat is 3000.

How to create your own Chat server like WhatsApp

Next, you will enter the required and appropriate information for you to complete the initial setup. The next steps will make it possible for the chat application to connect to the chat server.

Connect to Chat Server

First, a free domain name and nothing better than Duck DNS. Here I have created a domain name routerbestchat.duckdns.org. 

Duck DNS

Just like the previous articles you go through the installation steps on ubuntu to update your public address. You choose your operating system and domain name, then follow the steps as instructed to install duck dns on ubuntu.

Please take care to correct the path to the executable and log files as I am doing.

How to create your own Chat server like WhatsApp

sudo nano duck.sh
sudo chmod 700 duck.sh
crontab -e

Choose 1 and use command

*/5 * * * * duck.sh >/dev/null 2>&1

How to create your own Chat server like WhatsApp

In addition to creating an executable you will schedule automatic updates of your public ip address. If at the last step you get an OK result, that means you have succeeded.

How to create your own Chat server like WhatsApp

Port Redirection

Because my chat server is on the local network and does not use the public ip address directly, I need to forward the port on the router. If you directly use the public ip address for your chat server, you can skip this step. As for my router, I need to forward two ports, which are 80 and 443. 

My chat server ip address is 10.11.32.98. You enter the correct port and ip address of your chat server to complete the port forwarding step on the router.

How to create your own Chat server like WhatsApp

After forwarding the port on the router, you go to the final step of this article which is to encrypt the communication between the chat client and the chat server.

Encrypt the Communication

You will also get instructions on rocket chat homepage. Here you just need to replace it with your domain name to complete the encryption configuration.

How to create your own Chat server like WhatsApp

sudo snap set rocketchat-server siteurl=https://<your domain>

Then don't forget to restart rocket chat for the configuration to take effect.

sudo systemctl enable --now snap.rocketchat-server.rocketchat-caddy 
sudo snap restart rocketchat-server

So I have installed and configured rocket chat server. Now I will use chat clients to connect to the server and send messages.

First, I use app chat on Windows. You enter your domain name then create a new account to be able to use your own chat application. 

How to create your own Chat server like WhatsApp

In addition to sending messages you can also attach files, pictures, videos, music.

Facebook: https://www.facebook.com/routerbest

Twitter: https://twitter.com/routerbestcom

Tags: WhatsApp Chat server Ubuntu rocket chat