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
Comment #1
darklrd CreditAttribution: darklrd commentedIs drupalchat_nodejs.server.extension.js in the same folder as server.js?
Comment #2
darklrd CreditAttribution: darklrd commentedAlso, which version of nodejs module are you using?
Comment #3
kt2ssh CreditAttribution: kt2ssh commentedI 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)
Comment #4
kt2ssh CreditAttribution: kt2ssh commentedwhen 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"
Comment #5
kt2ssh CreditAttribution: kt2ssh commentedFinally , 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
};
Comment #6
darklrd CreditAttribution: darklrd commentedThanks for documenting the steps.
Comment #8
shilpaKhanal CreditAttribution: shilpaKhanal commentedCofigured 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
Comment #9
Anonymous (not verified) CreditAttribution: Anonymous commentedI 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.
Comment #10
stewart.adam CreditAttribution: stewart.adam commentedFor what it's worth, this is my config file for "yourwebsite.com" with drupal installed in "subfolder":
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:
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.
Comment #10.0
stewart.adam CreditAttribution: stewart.adam commentedtypo
Comment #11
sukr_s CreditAttribution: sukr_s commentedwe 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.
Comment #12
czigor CreditAttribution: czigor commentedA valuable source of information is also https://www.drupal.org/node/1713530.