Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Does cluster support socket.io node? #95

Closed
lexer opened this Issue · 12 comments

6 participants

@lexer

Failed to find cluster google group. Does cluster support socket.io node?

@3rd-Eden

No, because your polling requests could go to different servers where the sessionId might be unknown.
But we are working on a Socket.IO (0.7) release that allows you scale over multiple processes.

@tj
tj commented

nope. like @3rd-Eden mentioned, it's more of an issue of socket.io not supporting multiple processes out of the box

@tj tj closed this
@xepcoh

Is it still the case with socket.io 0.8.4?

@3rd-Eden

@dimux333 yes, it's still the case for 0.8.4, however!

We recently landed the RediStore backend for Socket.IO which does allow you to run cluster together with Socket.IO.
I gave a small demo about this during my Nodejsconf.it session. You can find a working demo of this in my github repo (https://github.com/3rd-Eden/nodejsconfit-2011/tree/master/cluster) which will spawn a cluster of 40 processes with a working socket.io.

So support is definitely coming, but I was unable to get WebSockets working with Cluster but that could been the lack of time I had to fully investigate this behavior.

@xepcoh

Thanks. I'll take a look.

@DavidChouinard

@3rd-Eden & @xepcoh Sorry to revive this thread, but what's the status now? How's the support of Socket.io with Node's native cluster functionality?

@tj
tj commented

@DavidChouinard same thing as before, there's no such thing as "supporting node cluster", it's just the same-old multi-process issue, which you can get around by using redis etc

@3rd-Eden

@DavidChouinard @visionmedia The advised way is to the RedisStore that is inside of Socket.IO (https://github.com/LearnBoost/socket.io/blob/master/lib/stores/redis.js) which will make sure that Socket.IO runs with the native cluster implementation of Nodejs and the leanboost/cluster module.

For usage see my nodejsconf-it example that I posted above.

@DavidChouinard

@3rd-Eden

I copied the /socket/ directory of your repo (thanks!) and ran it. Every worker is spewing this error:

Error: Redis connection to 127.0.0.1:6379 failed - ECONNREFUSED, Connection refused
    at Socket.<anonymous> (/Users/david/Desktop/cluster/node_modules/socket.io/node_modules/redis/index.js:123:28)
    at Socket.emit (events.js:64:17)
    at Array.<anonymous> (net.js:830:27)
    at EventEmitter._tickCallback (node.js:126:26)

Clearly, the workers are failing to connect to Redis.

A bit of hacking around go me to this line:

io.set('store', new RedisStore);

My understanding is that the master is creating a Redis store and imposing Socket.io (and workers) to use it internally. Am I getting this right?

Am I supposed to somehow start Redis? Why is it failing to connect? Let me know.

Thanks!

@3rd-Eden

@DavidChouinard yes it requires Redis to be installed and running.

@DavidChouinard

@3rd-Eden Got it, thanks.

@rcombs

I've seen people go back and forward on this; can Socket.io work with multiple processes (including Node native socket on 0.8.0) if RedisStore is used?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.