I've been struggling with this for some weeks now and so far I have not found a proper solution yet. I guess this is a bug, but since there is no response on nodejs issue queue I'd like to ask this question here as well. (Drupal.org issue)

The situation:

I am working on a conference plugin using webRTC, where the initial handshake is done using Nodejs integration module. (Needed Nodejs for some other applications as well so I thought this would be the best way.) There is some documentation on how to send messages from client > node server > backend (> other clients). However for my handshake it has no added value to use the Drupal backend, so I want messages to go client > node server > channel.

The Nodejs integration module has settings for allowing clients to write to channels and in fact the messages arrive on the server, the server sends them to the connected clients and the clients reject the messages.

The idea:

I've tracked it down to the following piece of client side javascript in the nodejs module, where both message.clientSocketId and Drupal.Nodejs.socket.sessionid are undefined (thus equal) and the callback is left.

Drupal.Nodejs.runCallbacks = function (message) {
  // It's possible that this message originated from an ajax request from the
  // client associated with this socket.
  if (message.clientSocketId == Drupal.Nodejs.socket.sessionid) {

Is there somebody who managed to get client > node server > channel communication using only JavaScript? Did I miss an authentication step somewhere?

Commenting out the return statement does work, but then clients respond to their own messages, leading to undesired behavior.

  • Why are you using the drupal nodejs integration if you don't intend to use drupal backend? You could have the client connect from the page served from drupal directly on your node server. I'm not sure what you refer by channel, but if you want to implement realtime communication, I found socket.io a nice abstraction layer: npmjs.com/package/socket.io If you need to match the users on your node server with the users on your drupal server, it might be easier to send (from the browser) the session data (cookie) in a message to the node server and have a webservice on your drupal serve – Xavier Dec 23 '14 at 16:29
  • Thanks for your reply. The nodejs integration module uses socket.io in the background but also handles the registration of users on certain channels (also known as rooms or socket id's). This allows me to use the Drupal backend to give certain users access to certain channels. I'd rather use it this way then passing users around between two servers. – Neograph734 Dec 23 '14 at 16:36
  • Hi, Thanks for the clarifications. I'm not sure I understand your initial point about not needing the handshake. If it's the WebRTC handshake, you just need an ICE server (probably) and use the existing socket.io to communicate webrtc-experiment.com/docs/… As for your point about sessionid being null, are you sure you get the users properly connected? I wonder why it's null (and that's not linked to webrtc, it's more a socket.io problem) – Xavier Dec 23 '14 at 17:02
  • I need to do video conferencing, so it will be STUN/TURN server, and I want to make other clients aware of a new user in the room (handshake was not the right word). That's why I chose socket.io, but with the channel system from the node integration module. I wonder why it is null as well and that's why I suppose this is a bug (start of question). Users are properly connected and messages are sent and rejected on arrival. – Neograph734 Dec 23 '14 at 17:11
  • To elaborate, each user gets a socket.io id. But it is not stored in that variable. – Neograph734 Dec 23 '14 at 17:22

I can no longer reproduce this. Since the module did not update in the meantime I guess it a new version of socket.io that got updated via npm update.

The posts here have been of great help in further development of the functionality: http://theoleschool.com/tags/nodejs

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.