Flotype / now

NowJS makes it easy to build real-time web apps using JavaScript
http://www.nowjs.com
MIT License
1.92k stars 175 forks source link

/nowjs/now.js doesn't work in Express 3 #200

Closed goldfire closed 11 years ago

goldfire commented 12 years ago

When running Express 2.5.9 and below I can load the client script from /nowjs/now.js just fine, but when I switch to Express 3.0.0alpha2, I get:

Cannot GET /nowjs/now.js
strangelooper commented 12 years ago

In Express 3 'express' is a function not a server. So you have to pass it the server.

var server = http.createServer(app).listen(app.get('port'), function() {
    console.log('Express server listening on port ' + app.get('port'));
}

var everyone = require('now').initialize(server);
centerax commented 11 years ago

excellent, thanks gscmedia, this fixed my problem too, also removed the notice I was getting "Socket.IO's listen() method expects an http.Server instance as its first parameter. Are you migrating from Express 2.x to 3.x? If so, check out the "Socket.IO compatibility" section at: https://github.com/visionmedia/express/wiki/Migrating-from-2.x-to-3.x"

individual11 commented 11 years ago

For anyone in the future who runs across this thread, make sure you do the

var server = http.createServer(app);

before you do any of your app settings (e.g. app.use, app.set). It gave me serious trouble for hours.