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.
*****************************************************************************************************************
Admin can enable real-time chat from Theme Settings.
First, make sure that you have installed the node on your server.
Either it's shared hosting or dedicated hosting, and also make sure from your hosting provider that the port is enabled on which you have sent requests.
On shared hosting, contact your hosting provider and ask them to install node, so you can easily run the server.js file by writing this command node server.js from the terminal.
In the case of a dedicated server, you have full access to install the node.
After verifying Please ask your hosting provider to run server.js file through SSH commands
themes > workreap > js > server.js
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.
Then from Theme Settings, you can enable either Inbox or real-time chat.
Please replace the hostname with your site name like below
https://yourdomain.com
Just add your host and open port in Theme Settings. Please note if you have used port other than 81 then please update port in server.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 your domain, then make sure that you have access to your certificate files on your Cpanel.
Normally SSL certificate files could be found below the path on cpanel.
To make sure that which keys and cert file have been used for the 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 the certificate file and then go to SSL folder path. ( ssl/certs )
Download the file on your PC and then go to SSL/keys folder to download the key file.
After that go to your theme directory and create the below folder path in your theme root location.
/workreap/chat_ssl/
Rename both files so you can remember them easily.
And upload your downloaded key and cert file to this folder.
Now open workreap/js/server-ssl.js file
Now run the node server file from the terminal like this node server-ssl.js
And check the chat it will work now on HTTPS secure protocol.
Note: Only Authorized certificates install on your domain will be recognized for your chat node server and no self-signed certificate will work on the production server.
Extra Notes:
The below process is same for both situations either with SSL or without SSL.
Node JS Chat server is only available or worked if the terminal open, If you have mistakenly closed the terminal or logged out of your session then the node chat server will be stopped.
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 the background now.
To check which node processes are running on the background enter the following command.
forever list
(It will list down 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