How to Enable Real Time Chat

*****************************************************************************************************************

How to enable real-time chat

Please note real-time chat will only work if your server does support node.js and you are allowed to run forever commands to run server file. Mostly VPS and Dedicated servers allow you to run node server files.

*****************************************************************************************************************

First make sure that you have installed node and npm installed on your server. 

Either its shared hosting or dedicated hosting, and also make sure from your hosting provider that the port is enabled on which you have sending requests.

On shared hosting contact to your hosting provider and ask them to install node and npm, so you can easily run index.js file by writing this command node index.js from the terminal.

In case of dedicated server you have full access to install node and npm.

After verifying please ask your hosting provider to run index.js file through SSH commands

If you have not used any SSL certificate for your domain then without any problems you can run node chat server file. Just follow the below instructions.

Please ask your hosting provider to run index.js file through SSH commands, index.js file is located in (your-project > js > index.js) Please ask your hosting provider how we can setup node server file. You need to set server host and port from chat settings


Note: if you have used port other than 3001 then please update port in index.js as well.

In simple inbox system, users will get messages on page refresh while in real-time chat system users will get instant messages without refreshing the page. 

If you have used SSL certificate for you domain, then make sure that you have access to your certificate files on your cpanel.

Normally SSL certificate files could be found below path on cpanel.

To make sure that which keys and cert file have used for SSL certificate, you can find that information on Cpanel SSL/TLS

After that click on Manage SSL

After clinking on Managed SSL Sites.

Copy the name of certificate file and then go to SSL folder path. ( ssl/certs )

Download the file on you PC and then go to ssl/keys folder to download the key file.

After that go to you theme directory and create the below folder path in your theme js folder -> chat-cert folder.

if chat-cert folder is not exist then create chat-cert inside js folder and upload your downloaded key and cert file to this folder.

Now run the node server file from terminal like this node server-ssl.js

Note: Only Authorized certificates install on your domain will be recognize for your chat node server and no self-signed certificate will work on production server.

This below process is same for both situations either with SSL or without SSL.

Node JS Chat server only available or worked if terminal open, If you have mistakenly closed the terminal or logged out your session then the node chat server will be stop.

To run the node js chat app in background process install the npm process manager which is forever.

Run the below commands from your terminal.

npm install forever -g

It will install forever package globally, Note: If you have not installed forever globally then it will not work.

To start the node chat server run the following command.

forever start server-ssl.js

Do not bother the warnings it will run your application in background now.

To check which node processes are running on background enter the following command.

forever list 

(It will list down the all running processes for node js)

And to stop the node chat server enter the below command.

forever stop server-ssl.js

For your eyes only