node-zkplus icon indicating copy to clipboard operation
node-zkplus copied to clipboard

'connect' event is emitted multiple times

Open srcshelton opened this issue 10 years ago • 0 comments

(Possibly related to Issue #3 from 2012?)

I have a trivial code sample:

var zkplus = require( 'zkplus' );

var client = zkplus.createClient({
          connect: false
        , servers: [{
                  host: 'registry1'
                , port:  2401
          }]
        , timeout: 30000
});

client.on( 'connect', function() {
        console.log( 'DEBUG: connect called' );

        client.readdir('/', function( error, nodes ) {
                if( error ) {
                        console.log( 'Read error: ' + error );
                } else {
                        console.log( nodes.join() );
                }
                client.close();
        });
});

client.on( 'error', function( error ) {
        console.log( 'General error: ' + error );
});

client.connect( function( error ) {
        console.log( 'Connection error: ' + error );
        process.exit( 1 );
});

... which, with ZooKeeper 3.4.5 and nodejs v0.10.32 on Ubuntu 12.04 LTS always outputs:

DEBUG: connect called
DEBUG: connect called
<list of zookeeper nodes>
Read error: ZooKeeperError: zookeeper is closing

If connect is set to 'true' and the client.connect() function-call is commented out, then the onConnect callback never seems to be triggered at all.

srcshelton avatar Feb 10 '15 11:02 srcshelton