Okay
  Print

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 the Theme Settings

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 server.js file by writing this command node server.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 server.js file through SSH commands

Themes > doctreat > 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.

Please ask your hosting provider how we can setup node server file

Then from Theme Settings you can enable either Inbox or real-time chat

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 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 root location.

/doctreat/chat_ssl/

Rename the both files so you can remember them easily.

And upload your downloaded key and cert file to this folder.

Now open doctreat/js/server-ssl.js file


Now run the node server file from 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 recognize for your chat node server and no self-signed certificate will work on production server.

Extra Notes:

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