Add ability to specify port on io.connect #807

Closed
natestarner opened this Issue Mar 28, 2012 · 3 comments

2 participants

@natestarner

Right now, it is hard to work around most reverse proxies (nginx, HAproxy). I think a reasonable fix would be the ability to specify a port on io.connect as such:

io.connect("http://yourdomain:8080/chat"); // with namespace

So a sample workflow would be:
nginx listens on port 80
nodejs listens on port 8080
socket.io listens on port 8080 through nodejs app
nginx proxies any requests on port 80 over to nodejs on 8080
socket.io client connects directly to node/socket server on port 8080

@rauchg

This should be working already. Is it not?

@natestarner

Thank you for the reply.
My initial thought was that nginx was interfering. I am connecting fine via io.connect with a port specified, but when I broadcast to a room, I get empty objects on the client of the socket that broadcasts the event.
For example:
the server broadcasts this event:
socket.broadcast.to(pageID).emit('addOnlineUsers', {test:"a test"});

the corresponding client event gets fired (for the same socket that broadcast the event):
chat.on('addOnlineUsers', function(userData){
console.log(userData); //produces an empty object
});

I'm using socket.io v0.9.0
Thanks again

@natestarner

Fault on my end. Events are working as advertised and using a port to sidestep nginx seems to be a valid workaround for nginx not having native websocket support. Thanks again for the reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment