Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello,
I am trying to test how chat room works with nodejs, but I have run into a little bump in the road. See here:
info - socket.io started
publishMessageToChannel: The channel "chatroom_chat_305" doesn't exist.
publishMessageToChannel: The channel "chatroom_chat_305" doesn't exist.
No active sessions for uid: 1
When I proceed to write something in my newly created chat, no text will appear in my browser window until I do a manual refresh. I must be doing something wrong, do you have any ideas?
Best regards,
Ao
Comments
Comment #1
darklrd CreditAttribution: darklrd commentedHi
Did you check the server status at admin/config/nodejs/stats? Also, which version of node.js are you using?
Comment #2
Aonoa CreditAttribution: Aonoa commentedI am using version 7.x-1.0-beta1 of nodejs and the server stats page just gives me an error:
The commandline gives me this at the same time:
I'll look at some other versions of nodejs, then.
Best regards,
Ao
Comment #3
Aonoa CreditAttribution: Aonoa commentedBy switching to nodejs dev snapshot from 29th of June, I had some progress. The server stats page now gives me:
But, I do have a chat, although at this point I can't enter text in it. I no longer get "channel doesn't exist" messages, but I do get "No active sessions for uid: 1".
EDIT: I spoke too soon, I still get "channel doesn't exist" messages.
Best regards,
Ao
Comment #4
darklrd CreditAttribution: darklrd commentedHi
What is your node.js server version?
Comment #5
Aonoa CreditAttribution: Aonoa commentedThe latest from https://github.com/joyent/node
Best regards,
Ao
Comment #6
darklrd CreditAttribution: darklrd commentedBuild the v0.4 branch.
Comment #7
Aonoa CreditAttribution: Aonoa commentedFrom the server stats I still get:
Now the node.js displays:
The "Started http server" was not there before, and the "No active sessions for uid: 1" seems to be gone.
Best regards,
Ao
Comment #8
Aonoa CreditAttribution: Aonoa commentedI had used older versions, but trying latest https://github.com/senchalabs/connect and https://github.com/visionmedia/express does not help.
I'll also add my nodejs.config.js file here, just in case:
Best regards,
Ao
Comment #9
Anonymous (not verified) CreditAttribution: Anonymous commentedsubscribe.
Comment #10
darklrd CreditAttribution: darklrd commentedHi
Are you using the latest 7.x-1.x-dev, dated 2011-Jun-29, of nodejs module?
Comment #11
Aonoa CreditAttribution: Aonoa commentedYes, I am. I stated that already in #3. :-)
EDIT: Just adding file info from my downloaded tarball to let it be known it is the right version:
36406 Jun 29 14:14 nodejs-7.x-1.x-dev.tar.gz
md5sum: ec259999db1211cfca085cfc21ccdf23
Best regards,
Ao
Comment #12
Aonoa CreditAttribution: Aonoa commentedI have a "page not found" error on the following file:
sites/all/modules/nodejs/socket_io/socket.io/node_modules/socket.io-client/dist/socket.io.js
The socket.io directory contains only:
History.md Makefile Readme.md examples index.js lib package.json support test
I'll investigate further.
Best regards,
Ao
EDIT:
socket.io/lib/
contains:logger.js manager.js namespace.js parser.js socket.io.js socket.js store.js stores transport.js transports util.js
Is that the socket.io.js drupal was looking for?
Comment #13
Aonoa CreditAttribution: Aonoa commentedI made a new folder structure and symlink in
sites/all/modules/nodejs/socket_io/
so that it would see the propersocket.io.js
in the same directory it wanted.Now I get these messages:
Any ideas?
Best regards,
Ao
EDIT: I can add that server stats still shows:
Comment #14
Aonoa CreditAttribution: Aonoa commentedChanging the backendSettings host IP from the servers actual IP to 'localhost' made all the info/debug messages shown in #13 disappear. However, I still do not have a working nodejs integration with chatroom.
It's still claiming there are no authenticated clients and no active channels. I have to manually refresh my chat page after every input to see the written message, and every time I write a message I get:
No active sessions for uid: 1
in the console running node server.js.Best regards,
Ao
Comment #15
pavlosdan CreditAttribution: pavlosdan commentedHi Ao,
I had similar issues with what you are describing here and I had 'localhost' in my config as well.
After changing all my 'localhost' instances both in the 'nodejs.config.js' and in 'admin/config/nodejs/config' to the actual server name my site was on (in my case I had defined the server name to be my site's domain in my Virtual Host) everything started working.
Also, (maybe this is not required but I still did it) I changed the ports for nodejs from 8080 to 9080 just to make sure that nothing was interfering with it.
So in 'admin/config/nodejs/config' I have:
Node.js server host: 'example.com'
Node.js server port: 9080
and in my nodejs.config.js I have:
backendSettings = {
"scheme":"http",
"host":"example.com",
"port":"9080",
"key":"/path/to/key/file",
"cert":"/path/to/cert/file",
"resource":"/node.js/realtime",
"publishUrl":"/nodejs/publish",
"serviceKey":"",
"backend":{
"port":"8080",
"host":"example.com",
"authPath":"/nodejs/auth/"},
"clientsCanWriteToChannels":true,
"clientsCanWriteToClients":true,
"extensions":[["nodejs.server.extension.js"]],
"debug":true
}
Hope this is of some help.
Pavlos
Comment #16
Aonoa CreditAttribution: Aonoa commentedHello!
Thank you for your input, but so far it's not helping I'm afraid. Same as always. :-(
EDIT: It's weird, because I can definitely see on the console that the port 8080 or 9090 (if I change it) is being used and connections are established locally.
Best regards,
Ao
Comment #17
pavlosdan CreditAttribution: pavlosdan commentedHmmm it is indeed weird.
I have just gotten Chat Room from git and switched to the branch with the nodejs integration, enabled and configured its settings and ran some tests and it seems to be working fine for me.
Do the other submodules from nodejs work for you?
Comment #18
Aonoa CreditAttribution: Aonoa commentedI haven't tried the other submodules from nodejs.
I have tried the latest chatroom dev snapshot, and tried gsoc2011 as well as the 7.x-1.x branches from git. Similar results.
Maybe there's something wrong with my node/express/connect/socket.io setup.. It took a lot of searching around git repo's to find all the various parts and put them together..
Basically I put everything in /usr/local/lib/node and exported NODE_PATH to that directory. The symlinking of socket.io.js was a bit confusing, but after reading drupal error logs it appeared to want the following structure:
sites/all/modules/nodejs/socket_io/socket.io/node_modules/socket.io-client/dist/socket.io.js
How is yours?
Best regards,
Ao
Comment #19
Aonoa CreditAttribution: Aonoa commentedI am writing to provide a little more information after some more testing.
I have been using node 0.4, connect 0.5.10, express 1.0.7, and then I add modules for qs, mime, ugly-js and redis. I get an error when trying to run
node server.js
while using the 0.6 branch of socket.io as suggested in the readme in nodejs module. Latest git versions of socket.io and socket.io-client satisfies node, but as usual I am still not getting chatroom to work properly with nodejs.My drupal is version 7.4 and I also tried to setup all of this from scratch, but still no success. Latest chatroom and nodejs modules.
Best regards,
Ao
Comment #20
pavlosdan CreditAttribution: pavlosdan commentedHi Ao.
Any luck with this?
I have my socket.io installed under my nodejs module folder so my symlink looks like this:
socket.io -> /path/to/site/sites/all/modules/contrib/nodejs/node_modules/socket.io/
(ran the command from the nodejs directory as explained in the nodejs installation guide)
Pavlos
Comment #21
Aonoa CreditAttribution: Aonoa commentedReally?
In my nodejs directory (/path/to/site/sites/all/modules/nodejs), I have a subdirectory called socket_io with a README.txt that says this:
That does not seem to match up with what you have done?
I have to have this structure and file:
sites/all/modules/nodejs/socket_io/socket.io/node_modules/socket.io-client/dist/socket.io.js
, because if I don't, my drupal gives me page not found errors on that file. Maybe my nodejs module is different from yours?Another question, which versions of socket.io and socket.io-client are you using?
Best regards,
Ao
Comment #22
pavlosdan CreditAttribution: pavlosdan commentedIm using the dev version of nodejs.
from its readme file:
4. Create a symlink to the socket.io client in the `socket_io` folder (run from within the module's root directory)
ln -s `pwd`/node_modules/socket.io/ socket_io/socket.io
My socket.io version is 0.7.7 and my socket.io-client is version 0.7.4
Comment #23
Aonoa CreditAttribution: Aonoa commentedNow I got a bit further, after correcting the symlink and node_modules folder and setting the proper hostname instead of localhost. However, it crashed. I'll provide the log:
Best regards,
Ao
Comment #24
Aonoa CreditAttribution: Aonoa commentedStrange, after that previous crash drupal is giving me page not found errors on this file location: sites/all/modules/nodejs/socket_io/socket.io/node_modules/socket.io-client/dist/socket.io.js.
It's kind of frustrating that it almost worked once, and now nothing again. I didn't even change anything between the attempts.
I can add that after the crash, all javascripts stopped working. It turns out that the cause behind the javascript not working is actually related to the missing page error for socket.io.js, if I do a workaround by creating a directory called node_modules inside socket.io and copy socket.io-client into that, then things are almost working..
Now I at least have an authenticated client! Even though the realtime chatting still isn't quite there, I must figure out how to activate the channel I guess.
Best regards,
Ao
Comment #25
Aonoa CreditAttribution: Aonoa commentedA little more log data:
Best regards,
Ao
Comment #26
Aonoa CreditAttribution: Aonoa commentedI think I have discovered my problem. It seems to break apart because I have multiple sites open with nodejs enabled in my browser at once. I used to have a duplicate test site open in a different tab, and now I do not. Now I have just one nodejs site open in my browser, and it suddenly works without me having changed anything. I'll continue to investigate and test.
Best regards,
Ao
EDIT: It is crashing rather often, with this kind of output:
Comment #27
Aonoa CreditAttribution: Aonoa commentedMy initial support request problem here has been solved. Thank you for all assistance.
Closing issue. :-)
Best regards,
Ao