In a node with comments, I would like that comments get auto-updated when new comments (from other users) get submitted. Any chance to get this implemented with ajax-comments ?
I installed and tested nodejs if that matter.

Note: I thought I have read somewhere that ajax-comments had this feature with nodejs integration, but I can't find it any more, so I am putting it as a feature request.

CommentFileSizeAuthor
#8 node_config2.png38.99 KBsylvaticus
#8 node_config1.png18.54 KBsylvaticus
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

formatC'vt’s picture

Status: Active » Postponed (maintainer needs more info)

Yes, you can do this with nodejs. Just enable AJAX Comments Nodejs Integration module (this module a part of AJAX Comments module)

sylvaticus’s picture

Title: Auto-refresh of comments when any new comment is posted » Auto-refresh of comments when any new comment is posted is not working
Category: Feature request » Bug report
Status: Postponed (maintainer needs more info) » Active

Hi, thanks for the quick reply.
that's great.. however for some reasons here it's not working: comments get sent and self-sent comments correctly got displayed, but the comment section is not updated when a comment is sent from the other browser/user.

In the shell where I have nodejs opened I can read messages like:

setContentToken: message { token: '764ludOjLVM3REiV9g_0Ot-GhO_1okxEBZXFS6FQ1hw',
  channel: 'ajax_comments_nodejs_345',
  notifyOnDisconnect: false }
setContentToken 764ludOjLVM3REiV9g_0Ot-GhO_1okxEBZXFS6FQ1hw for channel ajax_comments_nodejs_345
setContentToken: message { token: 'MjD4XHN5T2SS1hAIobhcHCppTtV0Gnc_na7vp_bLqJg',
  channel: 'ajax_comments_nodejs_345',
  notifyOnDisconnect: false }
setContentToken MjD4XHN5T2SS1hAIobhcHCppTtV0Gnc_na7vp_bLqJg for channel ajax_comments_nodejs_345
publishMessageToContentChannel: message { channel: 'ajax_comments_nodejs_345',
  callback: 'ajaxCommentsNodejs',
  authToken: '[A RANDOM STRING]',
  action: 'added',
  cid: '217',
  clientSocketId: '' }
publishMessageToContentChannel: message { channel: 'ajax_comments_nodejs_345',
  callback: 'ajaxCommentsNodejs',
  authToken: '[A RANDOM STRING]',
  action: 'added',
  cid: '218',
  clientSocketId: '' }

However comments' page doesn't get updated. I debugged to Firebug but I don't have any error in the console.

I have created a test case here:
https://booksforum.org/content/chatroom/new-chat-room-test
with username test1 and test2 and password ajaxcomments

Please let me know how could I debug it further.

Thank you..

formatC'vt’s picture

this is can be a theme level issue, but thanks for a test case, i will do same tests tonight.

sylvaticus’s picture

Hi.. thanks again for the quick reply.
I reverted to the default D7 theme (Bartik), but changing theme seems to have no effect: comments don't get reloaded when nodejs broadcast the new comment from an other user (I now installed switchtheme so there is a block to switch to Bartik)...

formatC'vt’s picture

NodeJS doesn't work for me because of "GET https://localhost:8080/socket.io/socket.io.js"
and my localhost without nodejs =)

sylvaticus’s picture

Status: Active » Closed (works as designed)

I am sorry. I left the localhost default as for the server-to-server connections. I went trough the nodejs documentation up to "Test your configuration", I got the test message and I assumed it was working.
I'll have to grab now where to change localhost for my actual site name within the 4 different "host" parameters, but it's a problem of nodejs module configuration, this module should work as expected...

Thanks again for your support

formatC'vt’s picture

i have two host definitions in nodejs.config.js.
first - host name or IP address that the node server should listen on.
second - host name of the Drupal site

try this:

settings = {
  scheme: 'http',
  port: 8080,
  host: 'localhost',
  resource: '/socket.io',
  serviceKey: '',
  backend: {
    port: 443,
    host: 'booksforum.org',
    scheme: 'https',
    basePath: '',
    messagePath: '/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: [],
  clientsCanWriteToChannels: false,
  clientsCanWriteToClients: false,
  transports: ['websocket', 'polling'],
  jsMinification: true,
  jsEtag: true,
  logLevel: 0
};
sylvaticus’s picture

FileSize
18.54 KB
38.99 KB

Thanks again... I slightly modified the config file to use the https, otherwise I have an error in the Firefox console about not loading the content as it is a mixed http/https:

So my nodejs.config.js file is:

settings = {
  scheme: 'https',
  port: 8080,
  host: 'localhost',
  resource: '/socket.io',
  serviceKey: 'THE KEY SET IN admin/config/nodejs/js',
  backend: {
    port: 443,
    host: 'booksforum.org',
    scheme: 'https',
    basePath: '',
    messagePath: '/nodejs/message'
  },
  debug: true,
  sslKeyPath: '/etc/ssl/private/booksforum_org.key',
  sslCertPath: '/etc/ssl/certs/booksforum_org_startssl.crt',
  sslCAPath: '/etc/ssl/certs/startsll_SSLCA_class1.pem',
  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: [],
  clientsCanWriteToChannels: false,
  clientsCanWriteToClients: false,
  transports: ['websocket', 'polling'],
  jsMinification: true,
  jsEtag: true,
  logLevel: 0
};

But how should I set /admin/config/nodejs/config and - if needed - /admin/config/nodejs/js ?

Here is how I have set them:
/admin/config/nodejs/config :
config1
/admin/config/nodejs/js :
config2

In particular I have done anything other than following the nodejs documentation. I don't know what that socket.io and publish parameters refer, I left the default values...
I also opened the port 8080 in the firewall, but if I nmap it I have it reported as close, unless I set the first host in nodejs config file as 0.0.0.0

SocialNicheGuru’s picture

Status: Closed (works as designed) » Active

when i enable "debug:true' in nodejs.config.js file I get this in the log when I click on save for my comment

publishMessageToContentChannel: message { channel: 'ajax_comments_nodejs_1',
callback: 'ajaxCommentsNodejs',
authToken: 'xxxxx',
action: 'added',
cid: '2',
clientSocketId: 'yyyyy' }
publishMessageToContentChannel: The channel "ajax_comments_nodejs_1" doesn't exist

formatC'vt’s picture

hm, channel should be created by ajax_comments_nodejs_process_node()

formatC'vt’s picture

oh, my bad, patch coming soon

  • formatC'vt committed 652e065 on 7.x-1.x
    Issue #2477235 by formatC'vt: Auto-refresh of comments when any new...
formatC'vt’s picture

Status: Active » Postponed (maintainer needs more info)

try latest dev, please

SocialNicheGuru’s picture

Status: Postponed (maintainer needs more info) » Needs work

Still got the same error:

'publishMessageToContentChannel: The channel "ajax_comments_nodejs_1" doesn't exist'

I am user 1.

formatC'vt’s picture

Status: Needs work » Postponed (maintainer needs more info)

ajax_comments_nodejs_X - where X number is node id, not user id.
I can't reproduce this bug, can you, please, give me more details about your case.

SocialNicheGuru’s picture

Status: Postponed (maintainer needs more info) » Active

I use nodejs with ajax_comments
nodejs is enabled properly
When I hit save on a comment, I see this in the nodejs debug log.
Shouldn't ajax_comments_nodejs_1 exist?

publishMessageToContentChannel: message { channel: 'ajax_comments_nodejs_1',
callback: 'ajaxCommentsNodejs',
authToken: '47f39c946ed7381dc3c36a386dcb4c6e',
action: 'added',
cid: '17',
clientSocketId: '' }
publishMessageToContentChannel: The channel "ajax_comments_nodejs_1" doesn't exist.

JuliaKoelsch’s picture

I was having the same issue, and found the cause for my situation: I am displaying comments on my page via the "Node Comment Block" module. So, when this module checks to see if it should enable the channel for the node being viewed (in ajax_comments_nodejs_process_node), the if statement fails because $variables['content']['comments'] is not set.

I removed this check from the if statement, and the auto-refresh worked perfectly!

Basically, I changed the first line of ajax_comments_nodejs_process_node(&$variables) in ajax_comments_nodejs.module (line 12) from this:

if (isset($variables['content']['comments']) && $variables['node']->comment == COMMENT_NODE_OPEN && ajax_comments_node_type_active($variables['node']->type)) {

to this

if ($variables['node']->comment == COMMENT_NODE_OPEN && ajax_comments_node_type_active($variables['node']->type)) {

@formatC'vt, would it be possible to make this modification, to support different ways of including comments on a page? I'm happy to supply a patch. I just didn't know if this modification would have unintended consequences.

Thanks!

  • formatC'vt committed fdb7e1c on 7.x-1.x authored by Spry_Julia
    Issue #2477235 by Spry_Julia: Auto-refresh of comments when any new...
formatC'vt’s picture

Status: Active » Postponed (maintainer needs more info)

yep, i agree, we should enable channel on all content with opened comments and enabled ajax_comments.
try latest dev, please.

JuliaKoelsch’s picture

Status: Postponed (maintainer needs more info) » Reviewed & tested by the community

Works perfectly. Thanks for committing it!

formatC'vt’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)
qzmenko’s picture

Status: Postponed (maintainer needs more info) » Fixed
qzmenko’s picture

Marked as "Fixed" because reviewed in comment #20

Status: Fixed » Closed (fixed)

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