Hi,

I am racking my brain over this, and thought it might be worth asking for help.

I have set up the latest version of this module, as well as nodejs and supporting modules as instructed in the README.

node server.js starts with info - socket.io started.

When I access pages on the drupal site and use Chrome's inspect tool, there is an error with socket.io.js because it only shows, "Welcome to socket.io" (which Chrome reads as a syntax error, haha). I also noticed that the inline js beneath socket.io.js is not being populated by anything as, I believe it should in order to tell socket.io what to do. Meanwhile on the Ubuntu server terminal where nodejs is running, I see the error, "unhandled socket.io url."

I have googled this issue a bit, and it suggests changing the version of socket.io, but I think there is something else going on because I think "Welcome to socket.io" is the default message when socket.io is being called, but with no request.

Any thoughts would be helpful. Thanks!

Eric

Comments

Equinger’s picture

still stuck. any ideas?

julien’s picture

What is your node version on the server? output of "node -v"
When you download the module, inside its directory, you should do 3 npm install:
npm install connect@1.1.4
npm install express@2.4.3
npm install request
Also you need to configure nodejs.config.js and also the backend settings.

carnau’s picture

I also faced this error some time ago, it's just a bad url in your backend config file that not points to the correct file.

You can check what values are used, placing this inside a hook_init().

function mymodule_init() {
  $nodejs_config = nodejs_get_config();
  $socket_io_config = nodejs_get_socketio_js_config($nodejs_config);
  print_r($socket_io_config['path']);
}
Equinger’s picture

That did it. Thank you!

Anonymous’s picture

Status: Active » Fixed

thanks carnau! closing now, please reopen if this didn't fix it.

Status: Fixed » Closed (fixed)

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

fenda’s picture

Status: Closed (fixed) » Active

Sorry for a re-open. I am getting the same issue.
I have a node JS server running and with the following test.js server, I can get the socket.io.js file:

var io = require('socket.io').listen(8080);

io.sockets.on('connection', function (socket) {
  socket.emit('news', { hello: 'world' });
  socket.on('my other event', function (data) {
    console.log(data);
  });
});

But when running the server.js file (in exactly the same folder as test.js) I can't get the socket.io.js file with the same URL that worked above.

My nodejs.config.js file:

settings = {
  scheme: 'http',
  port: 8080,
  host: 'localhost',
  resource: '/socket.io',
  serviceKey: 'HIDDEN',
  backend: {
    port: 80,
    host: 'pv.manpukukobo.jp',
    scheme: 'http',
    basePath: 'jfender',
    messagePath: '/nodejs/message'
  },
  debug: true,
  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: [],
  clientsCanWriteToChannels: false,
  clientsCanWriteToClients: false,
  transports: ['websocket', 'flashsocket', 'htmlfile', 'xhr-polling', 'jsonp-polling'],
  jsMinification: true,
  jsEtag: true,
  logLevel: 1
};
fenda’s picture

Fixed the problem. Not sure if this is a bug or not.

In nodejs.config.js the 'host' must be the actual nodejs hostname if accessed externally. So you cannot use 'localhost' or '127.0.0.1' for that.

Anonymous’s picture

Status: Active » Fixed

oh, yep, node will resolve the host and bind on that ip.

Status: Fixed » Closed (fixed)

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