Socket.IO and Node.js Main Cluster

Can I use Socket.IO with a Node cluster (not an outdated module)?

I can shell out several employees and it seems to be working fine; however, when I open the connection, I get an error message:solve: warn - client not handshaken client should reconnect

Here's the corresponding code snippet (with a few simplified examples, for example, using the expressjs configuration):

if ( cluster.isMaster ) {
    for ( var i = 0; i < numCPUs; i++ ) {
        cluster.fork();
    }
} else {
    app.get('/', function (req, res) {
        res.sendfile( __dirname + '/public/html/index.html' );
    });

    io.configure( function() {
        var RedisStore = require('socket.io').RedisStore,
            opts = { host: 'localhost', port: 8888 };

        io.set('store', new RedisStore( { redisPub: opts, redisSub: opts, redisClient: opts } ));
    });

    app.listen( 8888 );

    io.sockets.on('connection', function (socket) {
        socket.emit( 'some', 'data' );
    });
}

I tried to use RedisStore without and with a trick on this site (which, it seems to me, is now outdated): http://www.danielbaulig.de/socket-ioexpress/

I also looked at the code http://www.ranu.com.ar/2011/11/redisstore-and-rooms-with-socketio.html , although I do not see how this code differs from using MemoryStore.

Websockets (RFC 6455). , numCPU 1.

Node.js 0.6.17 Socket.io 0.9.5 Expressjs 2.5.9

- ( , , ):

info  - socket.io started
info  - socket.io started
info  - socket.io started
info  - socket.io started
info  - socket.io started
debug - served static content /socket.io.js
debug - client authorized
info  - handshake authorized 17644195072103946664
debug - setting request GET /socket.io/1/websocket/17644195072103946664
debug - set heartbeat interval for client 17644195072103946664
debug - websocket writing 7:::1+0
warn  - client not handshaken client should reconnect
info  - transport end (error)
debug - set close timeout for client 17644195072103946664
debug - cleared close timeout for client 17644195072103946664
debug - cleared heartbeat interval for client 17644195072103946664
debug - discarding transport
debug - client authorized
info  - handshake authorized 16098526291524652257
debug - setting request GET /socket.io/1/websocket/16098526291524652257
debug - set heartbeat interval for client 16098526291524652257
debug - websocket writing 7:::1+0
warn  - client not handshaken client should reconnect
info  - transport end (error)
debug - set close timeout for client 16098526291524652257
debug - cleared close timeout for client 16098526291524652257
debug - cleared heartbeat interval for client 16098526291524652257
debug - discarding transport
debug - client authorized
info  - handshake authorized 13419993801561067603
debug - setting request GET /socket.io/1/websocket/13419993801561067603
debug - set heartbeat interval for client 13419993801561067603
debug - client authorized for 
debug - websocket writing 1::
debug - websocket writing 5:::{"some":"data","args":[11354]}
debug - websocket writing 5:::{"some":"data","args":[36448]}

, ( 9 10):

info  - transport end by forced client disconnection
debug - websocket writing 0::
info  - transport end (booted)
debug - set close timeout for client 1639301251431944437
debug - cleared close timeout for client 1639301251431944437
debug - cleared heartbeat interval for client 1639301251431944437
debug - discarding transport
debug - got disconnection packet
debug - got disconnection packet

- github:

https://github.com/LearnBoost/socket.io/issues/881

https://github.com/LearnBoost/socket.io/issues/438

+3
1

, node, Socket.IO.

redis (npm install hiredis redis) RedisStore redis, . ~ 500 , node .

hiredis@0.1.14 redis@0.7.2

Redis 2.6rc3 6379.

: Node.s 0.8, , , /​​, , : http://nodejs.org/docs/v0.7.8/api/cluster.html

+3

All Articles