Skip to content
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

Closing connections #82

Open
misterdai opened this issue Jun 15, 2015 · 1 comment
Open

Closing connections #82

misterdai opened this issue Jun 15, 2015 · 1 comment

Comments

@misterdai
Copy link
Contributor

I can't seem to have the HBase client close all connections and all the Node.js process to exit normally. I've tried iterating the client.servers and calling .close() against each of them but I just receive a message about the connection being closed with no error and the Node.js process stays open (no other code is contained).

Exampe:

var HBase = require('hbase-client');
var client = HBase.create({zookeeperHosts: ['127.0.0.1:2181']});

client.getRow('table', 'rowName', ['field'], function(err, row) {
  console.log(row);
  // How do I close the connection?
  for (var name in client.servers) {
    console.log('Closing connection to ' + name + '.');
    client.servers[name].close();
  }
});

This script, doesn't ever finish executing for me.

@misterdai
Copy link
Contributor Author

Looking further into this, it appears that the Zookeeper client is still keeping the connection open. The following will work...

var HBase = require('hbase-client');
var client = HBase.create({zookeeperHosts: ['127.0.0.1:2181']});

client.getRow('table', 'rowName', ['field'], function(err, row) {
  console.log(row);
  // Closing the connection(s)
  for (var name in client.servers) {
    console.log('Closing connection to ' + name + '.');
    client.servers[name].close();
  }
  client.zk.close();
});

However, I'd like to suggest that this be incorporated into this module rather than having to perform it manually. For example client.close([callback]) could close all the server connections and the Zookeeper connection, finally calling an optional callback when complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant