New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Socket.io not serving its .js file with connect #500
Comments
same issue here |
@Margh with 2.x or 1.x? |
2.x for me, it still works in 1.x |
probably just needs a few tweaks for 2.x in socket.io or browserify |
same here, connect 2.x on its own doesn't work but express with connect 1.8.5 works |
so far, with what digging I've done, it looks like the server events for connection, request, etc aren't making it out through connect. This isn't allowing socket.io to catch and act on those. |
k with 2.0.3 try
|
We've figured it out with our setup. Basically, express/connect now returns the server object that will have the events when calling listen on the app. So, we're then storing that as a property of the app and then sending that property to socket.io instead of the app itself, which is how we did it with the old version. This also requires us to not startup our socket code until after the listen method has been called so that the server object is available. |
Yep, basically: // where this = express();
this.server = this.listen(this.config.port);
console.log('[ ' + this.constants.name + ' ] worker listening on port ' + this.config.port);
this.emit('listen', this.server); The I like that in Connect 2 / Express 3 it's possible to create an app without starting an http.server - so maybe our solution (creating app.server and emitting an event) is the way to go. |
moving forward both express/connect "apps" are just callbacks, giving people flexibility to apply it to both HTTP[S] servers if necessary, |
We override the |
Yeah things seem to work okay now that we've added our own record for the HTTP server and are passing that to socket.io instead. @guille Going forward should we look at engine.io or websocket.io in place of socket.io? We already opt for ws in simple cases. |
@hunterloftis |
going to close now that I get what the problem is :D haha yeah for future reference if anyone comes to this issue, you need to wrap the connect/express app in a node var io = require('socket.io');
var app = connect();
var server = app.listen(3000);
io.listen(server); or the following is equivalent: var io = require('socket.io');
var http = require('http');
var app = connect();
var server = http.createServer(app);
server.listen(3000);
io.listen(server); |
How would this work behind vhost? My engine.io server (ws.localhost) isn't actually calling app.listen(8080). |
Socket.io doesn't seem to be serving up its socket.io.js file with connect. I swapped connect out for express and everything worked fine.
See https://gist.github.com/1977521
The text was updated successfully, but these errors were encountered: