Last updated 12 August 2016. Created on 4 August 2012.
Edited by Gergely Lekli, geraldvillorente, Jaya M, xangy. Log in to edit this page.

This module adds Node.js integration to Drupal. It provides an API that other modules can use to add realtime capabilities to Drupal, such as push notifications or chat. The module relies on a Node.js server application that maintains an open connection with the visitor's browser to enable instant communication. In order to use this module, you will need to install the Node.js application on a server.

For an overview of what Node.js is and why you would use it with Drupal, watch this What is Node.js video from Drupalize.Me. Note that the installation procedure has changed, and the video may be outdated.

Installation

1. Install Node.js on your server, if not installed yet. Download the installer and follow the instructions on the Node.js website: https://nodejs.org/en/download/

2. Install the drupal-node.js server application and ensure that the application is running. Follow the instruction on GitHub:
https://github.com/beejeebus/drupal-nodejs

3. Install and enable the Node.js integration Drupal module on your site.

4. Visit the Node.js configuration page under the Configuration menu, and enter the connection information for your Node.js server application. The protocol, port, and service key settings should match the settings you entered in the config file of the Node.js server application. The host should be set to the hostname of the server on which you installed the Node.js server application. This host needs to be publicly accessible (i.e. "localhost" will not work).

5. Visit the status page of your Drupal site and ensure that there are no errors. Node.js should report that it has successfully connected to the Node.js server.

Note: The Drupal module and Node.js server application are sensitive to version numbers. The Drupal status page will show an error if the versions are not compatible.

Should you need any assistance with the installation, please feel free to open a support request in the module's issue queue.

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

menhio’s picture

Does any body knows how to fix this?

blur702’s picture

One problem I found was that the server stopped processing requests after a while. While this didn't lead to an error, it did cause the functionality of server.js to stop. To keep this alive, you might want to look into forever
Note:This is not a fault of this module, but just a handy thing to know about running node.js

W.M.’s picture

I appreciate the efforts put into documentation here. But you need to give more details as to how to get this thing working. Back-end, hosts, ip, ports, config here, config there .. ssl, HOWTO .. I simply cannot get this thing to work.

Kebz’s picture

When I installed the module, didn't it already install the necessary files? I'm looking for documentation to do the configurations properly within my http://xxx.com/?q=admin/config

My "readme.txt" file has the content quoted below.

Node.js integration
===================

This module adds Node.js integration to Drupal.

Setup
=====

1. Install Node.js.

1a. Install from a package manager:

https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager

1b. Install from the Node.js project website:

http://nodejs.org/download/

2. Install required Node.js modules with the Node Package Manager (NPM).

Make sure you are in the nodejs module directory - NPM needs the package.json
file that comes with the nodejs module to install the right modules.

cd path/to/your/nodejs/module/directory
npm install

3. Create a 'nodejs.config.js' file in your nodejs module directory.

Read the 'nodejs.config.js.example' file. A basic configuration can be as simple as:

settings = {
      host: '*',
      resource: '/socket.io',
      serviceKey: 'CHANGE ME',
      backend: {
        port: 80,
        host: 'changeme.example.com',
      },
      debug: true,
      transports: ['polling', 'websocket']
    };

Set debug to false when you are happy with your setup.

4. Run the node server with the command:

node server.js

To get a bunch of debug information, run server.js like this:

DEBUG=* node server.js

~Kebz

W.M.’s picture

@Kebz

Thanks for sharing. I get this error:

Started http server.

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: getaddrinfo ENOTFOUND
    at errnoException (dns.js:37:11)
    at Object.onanswer [as oncomplete] (dns.js:124:16)

I think it is related to this:

settings = {
      host: '*',
Kebz’s picture

You're welcome! I hope it helped you and found a solution.
Mine is currently disabled cause it doesn't want to play nice with me. lol

~Kebz

W.M.’s picture

@Kebz

I have disabled it too. I have spent long hours and tried all sort of configurations, but nothing made it work at all. Effort is put into this project but unfortunately there is some lack of documentation or to be fair, there is some information gaps for people like me with no previous experience with Node.js. All the best.

Kebz’s picture

awww... you too? So sorry it didn't work for you either.

Too many unresolved errors =\ ... the NodeJs website lacks proper documentation too. I'm determined to resolve this and have it running one of these days.... lol. In the meantime, it stays disabled. Thanks for the chat!

Error reaching the Node.js server at "nodejs/publish" with {"clientSocketId":""} "%{"clientSocketId":""}": [-111] Connection refused.

Error reaching the Node.js server at "nodejs/content/token" with {"token":"Xwxd2vk__r-hklX4NI5pffU3_Lx-Yo-zA_6oqC3znD4","channel":"watchdog_dblog","notifyOnDisconnect":false} "%{"token":"Xwxd2vk__r-hklX4NI5pffU3_Lx-Yo-zA_6oqC3znD4","channel":"watchdog_dblog","notifyOnDisconnect":false}": [-111] Connection refused.

~Kebz

Niklan’s picture

Also if you have vis message, this mean port is already in use.

richaAnkit’s picture

For better configuration select the nodejs.config.js content from

Home » Administration » Configuration » Nodejs >> CONFIGURATION BUILDER >>Suggested configuration. After doing all the setup in module node .

sathishdevan87’s picture

Is it possible to run Nodejs Server in a Separate Instance other than instance where drupal is deployed? Since nodejs server needs more memory I am planning to install nodejs in a separate server and use it with drupal. Please let me know how to configure it.

jukka792’s picture

Hi,

Did you manage to install nodejs on separate instance? I installed it but don't know how to connect from another instance to another. What to put in the field "node.js server host"

biggbest’s picture

Hi !

I'm actually wondering how is it possible to emit an authentication (username / password) to the server ? :(

If anyone here could help me, thank you !

EDIT: To be more accurate, I'm currently working on a node webkit (standalone app) project, using Drupal as a backend, and of course NodeJS Integration module. And I just would like to achieve an authentication from the node webkit app.

mwm’s picture

In my case, host: '*' was causing this error:
warn: error raised: Error: getaddrinfo ENOTFOUND

I tried specifying the hostname of the server with e.g.: host: 'example.com' , but this caused node.js to bind to only the IPv6 address of the server, and IPv4-only end users couldn't connect to it.

Solution: to run it in dual-stack mode, use host: '::' . The node.js server will then support either IP version. Whether this trick will work depends on the default socket options for your OS (IPV6_V6ONLY), and whether they allow you to bind a single socket on both address families at once. A workaround for that is to create a new hostname for the node.js server that only has an 'A' record (that won't give you IPv6 support, but at least it will get you up and running).

winnie80’s picture

thanks for this documentation, but will this also work on drupal 6 version of nodejs integration module?

png’s picture

In step 2, do we cd to the folder of nodejs installation, or the drupal nodejs module?

Also, why I am not seeing the server.js file?

Cheers.

CampRep’s picture

It seems there was drastic changes in file and folder structure from nodejs 7.10 version.
Documentation needs to reflect changes to newer version. I have no idea now how to set-up separate nodejs server. Running on Centos 7 linux.

MariaIoann’s picture

I have just installed node.js module with above instructions. It seems that the file is now named *app.js*.

png’s picture

Where is app.js? It is not in the nodejs module folder.

Cheers.

MariaIoann’s picture

I forgot to mention that after downloading the drupal module node.js, I then installed drupal-node.js packge with npm, as described in the modules README.txt file (which is also not mentioned in this post):
npm install drupal-node.js

png’s picture

.

png’s picture

Entered messages not shown in chat box except after page reload: anyone experiencing this in Drupal 7 recently?

Any advice on how this is solved is welcomed.

Cheers

CampRep’s picture

The documentation on this page works perfectly fine for the OLD nodejs version 7.x-1.10.
I have version 7.x-1.10 but I am not going to update to the new version on the project page because there are no clear simple steps on how to set up a separate instance.
These instructions needs to be updated. On how to install it on a separate instance and run the new "app.js" file

WisTex’s picture

Are there any directions for people who are using shared hosting and do not have command line access?

png’s picture

Just got into web site hosting, but I am sure you can use SSH on cPanel.

seehou’s picture

The documentation clearly is for older version.

I downloaded the latest version and I just couldn't connect to the node server.

Anyone has step by step instructions to integrate node & drupal? A simple one will do.

W.M.’s picture

Please update the documentation

Jaya M’s picture

I got it working with version 7.x-1.11. Here are step by step instructions,
1. Install and enable required node.js modules (nodejs config, nodejs notification, etc).
2. update Drupal's settings.php with required configurations (at least nodejs_service_key).
3. Update Node.js configuration from Drupal's admin page.
4. Install nodejs somewhere outside Drupal installation path. (eg. {HOME}/dev/).
-> curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
-> sudo apt-get install -y nodejs
5. Install the drupal-node.js module.
-> npm install drupal-node.js
6. create nodejs.config.js from node_modules/drupal-node.js/nodejs.config.js.example. Edit as required. Make sure that the key matches.
7. Run drupal-node.js application.
-> cd node_modules/drupal-node.js
-> nodejs app.js
8. Test the broadcast message as mentioned in the documentation.

Make sure you are using latest version of drupal-node.js module. The Drupal module and node modules are sensitive to version numbers.

arulraj’s picture

The reports page am can able to see "The Drupal-Node.js server (version 1.0.9) was successfully reached." i don't know how to test its working or not. i tried "System-wide Broadcast Notification" but no luck.

Michael_Lessard_micles.biz’s picture

My feedback will be obvious, as it most probably is what many think without saying it.

- A module is installed by simply placing its folder in /sites/.../modules;
- A library is simply placed in the the folder /sites/.../libraries

... installing outside the Drupal site root ; entering x commands ; editing this and that file ; entering host and password...

The concept of the module is cool, but there are too many "outside the box" elements which, in my opinion, can even create vulnerabilities.

Michael Lessard
webmaster of Quebec City "democracy in action" media
- migrated from Drupal 6 to Drupal 7 (was a long process)

Gergely Lekli’s picture

The documentation has been updated to reflect the latest version of the module. I hope this helps.
If you have any trouble with installation, please file an issue on the module page instead of commenting here. That way the issue will be handled more effectively.

W.M.’s picture

@Gergely Lekli .. Thank you very much.

png’s picture

Please take a moment to look at my question and help out, if you can.

http://drupal.stackexchange.com/questions/206108/nodejs-server-set-up

Any help is appreciated.

Gergely Lekli’s picture

I have posted a reply to your question.
Please submit any support requests to the module's issue queue instead of commenting here.

rakeshjha1993’s picture

I integrated nodejs on localhost and it is working fine on that. But when I work on server, drupal is connected with node js ( according to Status report ) but Ajax commenting is not working, and even broadcast message is not displaying.

My nodejs.config.js file is:

settings = {
scheme: 'http',
port: 8080,
host: 'linode.createlli.com',
resource: '/socket.io',
serviceKey: 'ravi',
backend: {
port: 80,
host: 'linode.createlli.com',
scheme: 'http',
basePath: '/devel/devcity/',
messagePath: '/nodejs/message'
},
debug: false,
sslKeyPath: '',
sslCertPath: '',
sslCAPath: '',
baseAuthPath: '/nodejs/',
extensions: [],
clientsCanWriteToChannels: false,
clientsCanWriteToClients: false,
transports: ['websocket', 'polling'],
jsMinification: true,
jsEtag: true,
logLevel: 1
};

and nodejs config page is :

protocol used: http

node.js server host: linode.createlli.com

port: 8080

pages on which to enable node js: *

Service Key: ravi

and domain for my site is city.devel.createlli.com

Gergely Lekli’s picture

Please feel free to open a support request in the module's issue queue.
Let's limit the discussion here to questions closely related to the documentation, because the length of this page is getting unruly.

kandrupaler’s picture

I've opened a new issue at https://www.drupal.org/node/2816499. Everything goes fine but I don't get the broadcast notifications whatever I do. Please take a look at the issue. I've taken close to an hour to write it and it's something I'm breaking my head over from 24 hours...