1

I'm trying to use socket.io with express 4 and express-generator, however I'm having an issue that the connection event from socket.io don't fires. I have the following settings for my project:

./bin/www

var load = require('express-load');

/**
 * Create HTTP server.
*/

var server = http.createServer(app);
var io = require('socket.io').listen(server, {});
load('sockets').into(io);

socket/chat.js

module.exports = function (io) {
   var sockets = io.sockets;

   sockets.on('connection', function (client) {
        console.log('A user had connected: ', client);
   });

   console.log('Sockets Events: ', sockets._events.connection);
};

The function of the event is properly logged to the conseole, but when I try to connect I don't receive the log from the event.

I already tried the solutions on this thread: Using socket.io in Express 4 and express-generator's /bin/www

But none solved my issue, thanks in advance.

Community
  • 1
  • 1
Rodrigo Valente
  • 319
  • 3
  • 17

0 Answers0