The following server.js works for me:
module.exports = server; var express = require('express'); var fs = require('fs'); var server = express.createServer(); var port = 58000; server.listen(port); var io = require('socket.io').listen(server); server.use(express.static('/', __dirname + '/../public')); server.use(express.logger()); io.on('connection', function(client){ console.log('new client connected ' + client); client.on('message', function(){ console.log('client wants something'); }); });
Simple express.static server for files in / subfolder, plus socket.io function. With this setting, any request for socket.io.js is not executed, i.e.
http:
returns 404 error (file not found). The static file server is working correctly. If I just use the "http" module instead of the "express" (commenting out express.static and express.logger lines), socket.io.js is served correctly. How can I combine both functions?
daaanipm
source share