Here is my step to config nodejs backend :
1. dl nodejs-7.x-1.x-dev , drupalchat-7.x-1.0-dev to /sites/all/modules.

2. copy drupalchat_nodejs.server.extension.js to /sites/all/modules/nodejs folder.

3. nvm use 0.6.0

4. npm install -d ( it install the following packages)
connect@1.8.5
express@2.5.6
request@2.9.100
socket.io@0.8.7

5. settup nodejs.config.js in nodejs folder as follow:
backendSettings = {
"scheme":"http",
"host":"192.168.1.112",
"port":8080,
"key":"/path/to/key/file",
"cert":"/path/to/cert/file",
"resource":"/socket.io",
"publishUrl":"/drupal-7.10/nodejs/publish",
"serviceKey":"",
"backend":{
"port":80,
"host":"192.168.1.112",
"messagePath":"/drupal-7.10/nodejs/message"},
"clientsCanWriteToChannels":false,
"clientsCanWriteToClients":false,
"extensions":['drupalchat_nodejs.server.extension.js'],
"debug":true,
"transports":["websocket",
"flashsocket",
"htmlfile",
"xhr-polling",
"jsonp-polling"],
"jsMinification":true,
"jsEtag":true,
"logLevel":1};

6. go to drupalchat config page and turn nodejs on.

7. go to nodejs page and set the hostname to my internal ip 192.168.1.112 ( I dont know y it doesn't work with localhost).

8. type node server.js
console output :

Started http server.
info - socket.io started
// login http://192.168.1.112/drupal-7.10/ with root

Authenticating client with key "ed9b084518fc5ecfa2a0000c7f58fd84"
Sending message to backend { authToken: 'ed9b084518fc5ecfa2a0000c7f58fd84',
messageType: 'authenticate',
clientId: '1363789804711401529' } { uri: 'http://192.168.1.112:80/drupal-7.10/nodejs/message',
body: 'messageJson=%7B%22authToken%22%3A%22ed9b084518fc5ecfa2a0000c7f58fd84%22%2C%22messageType%22%3A%22authenticate%22%2C%22clientId%22%3A%221363789804711401529%22%7D&serviceKey=',
headers:
{ 'Content-Length': 172,
'Content-Type': 'application/x-www-form-urlencoded' } }
Valid login for uid " 1 "
sendPresenceChangeNotification 1 online { '1': [] }
Auth - 1
Sent message to client 1363789804711401529
Added - 1
Added channels for uid 1: nodejs_user_1,nodejs_ajax_broadcast,watchdog_dblog
setupClientConnection { '1': [] }
getNodejsSessionIdsFromUid { uid: '1', sessionIds: [ '1363789804711401529' ] }
Added channel 'drupalchat_1' to sessionIds 1363789804711401529
Added channel 'drupalchat_1' authenticatedClients
---------------------------------------------------------------------------------------
the nodejs backup seem working but drupalchat no response , no user online ...
whats wrong with my nodejs config ?

Comments

darklrd’s picture

Is drupalchat_nodejs.server.extension.js in the same folder as server.js?

darklrd’s picture

Also, which version of nodejs module are you using?

kt2ssh’s picture

I m using nodejs-7.x-1.x-dev
drupalchat_nodejs.server.extension.js is in the nodejs module folder (the same folder of server.js)

kt2ssh’s picture

when I goto these links

http://192.168.1.112/drupal-7.10/nodejs/message
{"error":"Invalid service key."}

http://192.168.1.112:8080/
Not Found.

when I reload the page
firebug show an error
"ws://192.168.1.112:8080/socket.io/1/websocket/11599588211189690972 the connection is interrupted"

kt2ssh’s picture

Finally , I change the document root to drupal-7.10 , and then I copy the nodejs.config.js.example and modify as follow ,it works !

settings = {
scheme: 'http',
port: 8080,
host: '192.168.1.112',
resource: '/socket.io',
serviceKey: '',
backend: {
port: 80,
host: '192.168.1.112',
scheme: 'http',
basePath: '',
messagePath: '/nodejs/message'
},
debug: false,
sslKeyPath: '',
sslCertPath: '',
baseAuthPath: '/nodejs/',
publishUrl: 'publish',
kickUserUrl: 'user/kick/:uid',
logoutUserUrl: 'user/logout/:authtoken',
addUserToChannelUrl: 'user/channel/add/:channel/:uid',
removeUserFromChannelUrl: 'user/channel/remove/:channel/:uid',
addChannelUrl: 'channel/add/:channel',
removeChannelUrl: 'channel/remove/:channel',
setUserPresenceListUrl: 'user/presence-list/:uid/:uidList',
addAuthTokenToChannelUrl: 'authtoken/channel/add/:channel/:uid',
removeAuthTokenFromChannelUrl: 'authtoken/channel/remove/:channel/:uid',
toggleDebugUrl: 'debug/toggle',
contentTokenUrl: 'content/token',
publishMessageToContentChannelUrl: 'content/token/message',
"extensions":['drupalchat_nodejs.server.extension.js'],
clientsCanWriteToChannels: false,
clientsCanWriteToClients: false,
transports: ['websocket', 'flashsocket', 'htmlfile', 'xhr-polling', 'jsonp-polling'],
jsMinification: true,
jsEtag: true,
logLevel: 1
};

darklrd’s picture

Status: Needs review » Fixed

Thanks for documenting the steps.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

shilpaKhanal’s picture

Cofigured node js as follows

1. node server version 0.6.0

2. drupalchat_nodejs.server.extension , server.js, nodejs.config.js all in same folder i.e. nodejs

3. in /nodejs/nodejs.config.js

backendSettings = {
'scheme': 'http',
'host': 'corporateclean',
'port': 8082,
'key': '/path/to/key/file',
'cert': '/path/to/cert/file',
'resource': '/socket.io',
'publishUrl': '/nodejs/publish',
'serviceKey': '',
'backend': {
'port': 80,
'host': 'corporateclean',
'messagePath': '/nodejs/message'
},
'extensions': ['drupalchat_nodejs.server.extension.js'],
'debug':true,
'clientsCanWriteToChannels': false,
'clientsCanWriteToClients': false,
'transports': ['websocket', 'flashsocket', 'htmlfile', 'xhr-polling', 'jsonp-polling'],
'jsMinification': true,
'jsEtag': true,
'logLevel': 1
};

4. In windows: npm in same folder as node.exe

5. in http://corporateclean:8082/nodejs/message => {"error":"Invalid service key."}
6. No online users shown by drupal chat

Anonymous’s picture

I used the configuration set by kt2 and node gives that:

publishMessageToChannel: The channel "drupalchat_c-0" doesn't exist. And I can't see the public chatroom.

Can you help me ?

Thanks.

stewart.adam’s picture

For what it's worth, this is my config file for "yourwebsite.com" with drupal installed in "subfolder":

settings = {
  scheme: 'http',
  port: 8080,
  host: 'yourwebsite.com',
  resource: '/socket.io',
  serviceKey: 'super,secret!service-key_here',
  backend: {
    port: 80,
    host: 'youwebsite.com',
    scheme: 'http',
    basePath: '',
    messagePath: '/subfolder/nodejs/message',
  },
  debug: false,
  sslKeyPath: '',
  sslCertPath: '',
  sslCAPath: '',
  baseAuthPath: '/nodejs/',
  publishUrl: 'publish',
  kickUserUrl: 'user/kick/:uid',
  logoutUserUrl: 'user/logout/:authtoken',
  addUserToChannelUrl: 'user/channel/add/:channel/:uid',
  removeUserFromChannelUrl: 'user/channel/remove/:channel/:uid',
  addChannelUrl: 'channel/add/:channel',
  removeChannelUrl: 'channel/remove/:channel',
  setUserPresenceListUrl: 'user/presence-list/:uid/:uidList',
  addAuthTokenToChannelUrl: 'authtoken/channel/add/:channel/:uid',
  removeAuthTokenFromChannelUrl: 'authtoken/channel/remove/:channel/:uid',
  toggleDebugUrl: 'debug/toggle',
  contentTokenUrl: 'content/token',
  publishMessageToContentChannelUrl: 'content/token/message',
  extensions: ['drupalchat_nodejs.server.extension.js'],
  clientsCanWriteToChannels: false,
  clientsCanWriteToClients: false,
  transports: ['websocket', 'flashsocket', 'htmlfile', 'xhr-polling', 'jsonp-polling'],
  jsMinification: true,
  jsEtag: true,
  logLevel: 1
};

On the Node.js "Configuration" page, the Node.js server host is "yourwebsite.com", port is 8080.

On the "Node.js configuration builder" page, set the host/port to the same as before, then configure:

  • Resource: /socket.io
  • Publish URL: /nodejs/publish
  • Service Key: super,secret!service-key_here
  • Backend -> Host: yourwebsite.com
  • Backend -> Port: 80
  • Auth Path -> Host: /nodejs/message
  • Extensions: drupalchat_nodejs.server.extension

I based the installation procedure on the instructions in this useful blog post: http://drupal.arxic.com/node/30

I too am now seeing the chatroom error. I have started a new issue for that as #1980644: Public chat not working with nodejs integration.

stewart.adam’s picture

Issue summary: View changes

typo

sukr_s’s picture

we had the same problem "no users online". we figured out that the "Chat list latency" was too low - 2 seconds. changing this to a higher value solved the problem.

czigor’s picture

A valuable source of information is also https://www.drupal.org/node/1713530.