I humbly apologize if this is nothing more than a minor configuration oversight on my part, but I've hit a brick wall with this and I'm not sure what to do now.

Here's what I have....

I have node js installed with Drupal-7.12. I also have drupalchat installed, but that's not my concern. I have been attempting to send messages with System-Wide broadcast and with Drush to no success.

The drush command does nothing. Neither do any of the other send messages. No effect on the log output at all. Other browsers not seeing the messages.

drush broadcast-message hello hello

My config: ( I have drupal in a subdirectory of the web docs directory as I am developing multiple sites.
// ------------------
backendSettings = {
scheme:'http',
host:'localhost',
port:8080,
key:'',
cert:'',
resource:'/socket.io',
serviceKey:"",
backend:{
port:80,
host:'localhost',
scheme: 'http',
//authPath:'/pdlite/nodejs/auth/',
messagePath:"/pdlite/nodejs/message"
},
debug:true,
sslKeyPath: '',
sslCertPath: '',
//baseAuthPath: '/pdlite/sites/all/modules/nodejs/',
publishUrl:'/pdlite/nodejs/publish',
kickUserUrl: '/pdlite/user/kick/:uid',
logoutUserUrl: '/pdlite/user/logout/:authtoken',
addUserToChannelUrl: '/pdlite/user/channel/add/:channel/:uid',
removeUserFromChannelUrl: '/pdlite/user/channel/remove/:channel/:uid',
addChannelUrl: '/pdlite/channel/add/:channel',
removeChannelUrl: '/pdlite/channel/remove/:channel',
setUserPresenceListUrl: '/pdlite/user/presence-list/:uid/:uidList',
addAuthTokenToChannelUrl: '/pdlite/authtoken/channel/add/:channel/:uid',
removeAuthTokenFromChannelUrl: '/pdlite/authtoken/channel/remove/:channel/:uid',
toggleDebugUrl: '/pdlite/debug/toggle',
contentTokenUrl: '/pdlite/content/token',
publishMessageToContentChannelUrl: '/pdlite/content/token/message',
clientsCanWriteToChannels:true,
clientsCanWriteToClients:true,
extensions:["drupalchat_nodejs.server.extension.js"],
transports:["websocket", "flashsocket", "htmlfile", "xhr-polling", "jsonp-polling"],
jsMinification:true,
jsEtag:true,
logLevel:1
};

My log file seems to show no indication of the actual messages I am trying to send. Though, I can successfully kick a user, but cannot message them.

Extension loaded: drupalchat_nodejs.server.extension.js
Started http server.
   info  - socket.io started
Authenticating client with key "8ad3def2958c9edbd8be599ea392df8a"
Sending message to backend { authToken: '8ad3def2958c9edbd8be599ea392df8a',
  messageType: 'authenticate',
  clientId: '1985516778192478506' } { port: 80,
  host: 'localhost',
  headers: 
   { 'Content-Length': 172,
     'Content-Type': 'application/x-www-form-urlencoded' },
  agent: 
   { options: { host: 'localhost', port: 80 },
     host: 'localhost',
     port: 80,
     queue: [],
     sockets: [],
     maxSockets: 5 },
  method: 'POST',
  path: '/pdlite/nodejs/message' }
Valid login for uid " 1 "
getNodejsSessionIdsFromUid { uid: 7, sessionIds: [] }
sendPresenceChangeNotification 1 online { '1': [ 7 ] }
Auth - 1
Sent message to client 1985516778192478506
Added - 1
Added channels for uid 1: nodejs_user_1,nodejs_ajax_broadcast,pdlite_emergency_channel,nodejs_notify,watchdog_dblog
setupClientConnection { '1': [ 7 ] }
getNodejsSessionIdsFromUid { uid: '1', sessionIds: [ '1985516778192478506' ] }
Added channel 'drupalchat_1' to sessionIds 1985516778192478506
Added channel 'drupalchat_1' authenticatedClients
getNodejsSessionIdsFromUid { uid: '1', sessionIds: [ '1985516778192478506' ] }
Added channel 'drupalchat_1' to sessionIds 1985516778192478506
publishMessageToContentChannel: message { channel: 'watchdog_dblog',
  broadcast: false,
  commands: 
   [ { command: 'insert',
       method: 'before',
       selector: '#admin-dblog tr:eq(1)',
       data: '<tr class="dblog-cron dblog-warning"><td class="icon"></td><td>cron</td><td>2012-02-03 15:49:22</td><td>Attempting to re-run cron while it is already running.</td><td><span class="username">Anonymous (not verified)</span></td><td></td></tr>',
       settings: null } ],
  callback: 'nodejsNodeAjax',
  clientSocketId: '' }
publishMessageToContentChannel: The channel "watchdog_dblog" doesn't exist.
publishMessageToContentChannel: message { channel: 'watchdog_dblog',
  broadcast: false,
  commands: 
   [ { command: 'insert',
       method: 'before',
       selector: '#admin-dblog tr:eq(1)',
       data: '<tr class="dblog-cron dblog-notice"><td class="icon"></td><td>cron</td><td>2012-02-03 15:49:22</td><td>Cron run completed.</td><td><span class="username">Anonymous (not verified)</span></td><td></td></tr>',
       settings: null } ],
  callback: 'nodejsNodeAjax',
  clientSocketId: '' }
publishMessageToContentChannel: The channel "watchdog_dblog" doesn't exist.
Out - 1
Cleaning up after socket id 1985516778192478506 uid 1
Authenticating client with key "8ad3def2958c9edbd8be599ea392df8a"
Reusing existing authentication data for key: 8ad3def2958c9edbd8be599ea392df8a , client id: 12577511521618476851
Auth - 1
Sent message to client 12577511521618476851
Added - 1
Added channels for uid 1: nodejs_user_1,nodejs_ajax_broadcast,pdlite_emergency_channel,nodejs_notify,watchdog_dblog,drupalchat_1
setupClientConnection { '1': [ 7 ] }
getNodejsSessionIdsFromUid { uid: '1', sessionIds: [ '12577511521618476851' ] }
Added channel 'drupalchat_1' to sessionIds 12577511521618476851
getNodejsSessionIdsFromUid { uid: '1', sessionIds: [ '12577511521618476851' ] }
Out - 1
Cleaning up after socket id 12577511521618476851 uid 1
Authenticating client with key "8ad3def2958c9edbd8be599ea392df8a"
Reusing existing authentication data for key: 8ad3def2958c9edbd8be599ea392df8a , client id: 2355172521849173361
Auth - 1
Sent message to client 2355172521849173361
Added - 1
Added channels for uid 1: nodejs_user_1,nodejs_ajax_broadcast,pdlite_emergency_channel,nodejs_notify,watchdog_dblog,drupalchat_1
setupClientConnection { '1': [ 7 ] }
getNodejsSessionIdsFromUid { uid: '1', sessionIds: [ '2355172521849173361' ] }
Added channel 'drupalchat_1' to sessionIds 2355172521849173361
getNodejsSessionIdsFromUid { uid: '1', sessionIds: [ '2355172521849173361' ] }

My versions are:
node v0.4.8 (I also tried with v0.4.7, no difference)
connect v0.1.8.5
express v2.5.6
socket.io v.0.8.7

From what I can tell, assigning user to channels seems to work. Users can see their buddy list with the 'chat' link. Actual chatting clearly won't work at this point.

I attempted step through the code with a debugger (macgdbp) and it kept freezing up so I wasn't able to step through and see what was going on.

Any ideas you can suggest are appreciated. I've been working at this for days.

debra

Comments

bigsyke’s picture

I just spent days trying to figure this out as well. If you cant see sitewide broadcasts on another browser window, I would change your config to this.

"resource":"/socket.io",
"publishUrl":"publish",
"messagePath":"/nodejs/message",

I think the problem is with the /pdlite/. I didnt start seeing the broadcasts on different browsers untill I removed the /nodejs/ from /nodejs/publish. Here is my config that finally got messages broadcasted. (still not getting chat go work)

backendSettings = {
"scheme":"http",
"host":"",
"port":8001,
"resource":"/socket.io",
"publishUrl":"publish",
"serviceKey":"23kj908342987dsaz",
"backend":{
"port":80,
"host":"192.168.0.90",
"messagePath":"/nodejs/message"},
"clientsCanWriteToChannels":false,
"clientsCanWriteToClients":false,
"extensions":[],
"debug":true,
"transports":["websocket",
"flashsocket",
"htmlfile",
"xhr-polling",
"jsonp-polling"],
"jsMinification":true,
"jsEtag":true,
"logLevel":1};

Obviously Ill fill in the host. But one of the problems was it was looking for a service key, and i couldnt find it in any of my config files.. Some how the Nodejs module's config builder screen saved it somewhere. So when I change something I have to change it in the module/nodejs and server's nodejs folder, along with the config builder screen.

debra-v’s picture

Bigsyke --
Thank you, thank you, thank you for giving me a bunch of clues.

ServiceKey did not work for me at all. So, per the advice from some other posts, I just left that blank and it seems to disregard it.

First, originally I was running this on my laptop (localhost) in a subdirectory htdocs. That added a level of difficulty apparently. I ended up shifting the whole project to one of the test servers here. I installed the correct versions of node, npm, connect, express, socket.io and began with a fresh nodes.config.js file.

Doing this added another challenge as the test server had SSL installed and was running as HTTPS, but I included the necessary changes in the config to reflect that. I also made sure the config settings matched the Nodejs config builder settings stored in the variable table.

Here's the config that worked for me....

backendSettings = {
scheme:'https',
host:'myserver.net',
port:8080,
key:'/etc/certificates/myserver.net.key',
cert:'/etc/certificates/myserver.net.crt',
resource:'/socket.io',
serviceKey:"",
backend:{
port: 443,
host:'myserver.net',
scheme: 'https',
messagePath: "/nodejs/message"
},
debug:true,
publishUrl:'/nodejs/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',
clientsCanWriteToChannels:true,
clientsCanWriteToClients:true,
extensions:[],
transports:["websocket", "flashsocket", "htmlfile",
"xhr-polling","jsonp-polling"],
jsMinification:true,
jsEtag:true,
logLevel:1
};

First, I think many of my original problems were first tied to the fact that I was trying to run this on localhost. It went so much more smoothly on a server with a static ip address.

Second, nodejs_notify relies on Growl notifications. Unfortunately, I was testing with Firefox 9+10. Growl does not seem to work with Firefox anymore. I didn't see messages until I switched to Safari and updated my growl extension.

Running Chrome with the Growl extension also displayed messages. Unfortunately, Chrome was triggering all sorts of errors from the nodejs server.js process. With Chrome, I frequently noticed "warn - websocket connection invalid" messages at the console.

Also... a more serious concern, which I think might be related to the website being HTTPS, lots of "Error sending message to backend: Parse Error" Although, many of those messages still manage to be delivered. Not sure what's going on there.

So, there's been lots of progress. We're excited to see how far we can integrate this into our system.

DebraV

Anonymous’s picture

Version: 7.x-1.0-beta6 » 7.x-1.0-rc1

please try against the latest release candidate.

debra-v’s picture

beejeebus --

You ROCK! Thank you for the weekend update about the latest release (7.x-1.0-rc1). That solved a number of my issues. I now have nodejs working with drupal installations on 2 servers, one http and one https.

The nodes additional commands no longer appear in the drush menu, though they still seem to work.

Working with this module has been a lot of fun. Let me know if there is any way I can help.

Thanks,

Debra V

Anonymous’s picture

Status: Active » Fixed

yay!

Status: Fixed » Closed (fixed)

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

attishu’s picture

We had the same issue. After 3 days we found the following solutions:

Use npm for check dependency!
Don't worry if say something "extraneous"! Sometimes this is the only way to make it work.
Node version: v0.10.26
Current configuration: (use npm ls command in your nodejs Drupal module folder)
Drupal-Node.js@1.0.2 /var/www/vhosts/your_domain_name/httpdocs/profiles/async/modules/contrib/nodejs
├─┬ connect@1.9.2 extraneous
│ ├── formidable@1.0.14
│ ├── mime@1.2.11
│ └── qs@0.6.6
├─┬ express@2.5.11
│ ├─┬ connect@1.9.2
│ │ └── formidable@1.0.14
│ ├── mime@1.2.4
│ ├── mkdirp@0.3.0
│ └── qs@0.4.2
├─┬ request@2.20.0
│ ├── aws-sign@0.3.0
│ ├── cookie-jar@0.3.0
│ ├── forever-agent@0.3.0
│ ├─┬ form-data@0.0.10
│ │ ├── async@0.2.10
│ │ └─┬ combined-stream@0.0.4
│ │ └── delayed-stream@0.0.5
│ ├─┬ hawk@0.10.2
│ │ ├── boom@0.3.8
│ │ ├── cryptiles@0.1.3
│ │ ├── hoek@0.7.6
│ │ └── sntp@0.1.4
│ ├─┬ http-signature@0.9.11
│ │ ├── asn1@0.1.11
│ │ ├── assert-plus@0.1.2
│ │ └── ctype@0.5.2
│ ├── json-stringify-safe@3.0.0
│ ├── mime@1.2.11
│ ├── node-uuid@1.4.1
│ ├── oauth-sign@0.3.0
│ ├── qs@0.5.6
│ └── tunnel-agent@0.3.0
└─┬ socket.io@0.9.16
├── base64id@0.1.0
├── policyfile@0.0.4
├── redis@0.7.3
└─┬ socket.io-client@0.9.16
├─┬ active-x-obfuscator@0.0.1
│ └── zeparser@0.0.5
├── uglify-js@1.2.5
├─┬ ws@0.4.31
│ ├── commander@0.6.1
│ ├── nan@0.3.2
│ ├── options@0.0.5
│ └── tinycolor@0.0.1
└── xmlhttprequest@1.4.2
-------------------------------------------------

At http://your_domain_name/admin/config/nodejs/config

Node.js server host: your_domain_name
Node.js server port: 8080

At http://your_domain_name/admin/config/nodejs/js fill the form properly. Save it. After you get the suggested configuration. We got the following:

/**
* This configuration file was built using the 'Node.js server configuration builder'.
* For a more fully commented example see the file nodejs.config.js.example in the root of this module
*/
backendSettings = {
"scheme":"http",
"host":"your_domain_name",
"port":8080,
"key":"/path/to/key/file",
"cert":"/path/to/cert/file",
"resource":"/socket.io",
"publishUrl":"publish",
"serviceKey":"your key",
"backend":{
"port":80,
"host":"your_domain_name",
"messagePath":"/nodejs/message"},
"clientsCanWriteToChannels":false,
"clientsCanWriteToClients":false,
"extensions":"",
"debug":true,
"transports":["websocket",
"flashsocket",
"htmlfile",
"xhr-polling",
"jsonp-polling"],
"jsMinification":true,
"jsEtag":true,
"logLevel":1};

Don't forget to copy this configuration to your nodejs.config.js

Once your server is running (#node server.js) check your firewall.
netstat -an | grep 80 | grep -i listen
Your port should be there.

Once it work you can disable debug and make other changes.

This configuration has been used on CentOS 5.9 VPS (Async distribution, after every module was updated)