Support Questions

Find answers, ask questions, and share your expertise

Couldn't establish Hive DB session in nodejs

avatar
New Contributor

Hi Team,

Good Day..

I'm beginner in Node.JS trying to connect Hive DB  using

hive-driver npm from Node.JS code.

I couldn't establish the db connection.

Any help would be much appreciated...

Note: Our Hive DB has ssl connection, jks trust store password, HTTP protocol , httppath=cliservice

 

NODE.JS  SAMPLE CODE:

client.connect(
{
host: 'jdbc:hive2://abc.com:2181/dev_db;ssl=true;sslTrustStore=/etc/hive-jks/hivetrust.jks;trustStorePassword=pro@!23;transportMode=http;httpPath=cliservice;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2',
port: 2181
},
new hive.connections.HttpConnection(),
new hive.auth.PlainHttpAuthentication({
username: 'username',
password: 'password'
})
).then(async client => {

console.log(client);

const session = await client.openSession({
client_protocol: TCLIService_types.TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V10
});

}).catch(error => {
console.log(error);
});

 

when I console.log client It's printing but I tried to open client.open session I've been facing issues 

Kindly check the host url string  which I've given right or not.

Could you please help on this issue.

PFB Error.

 

Viki_Nodejs_0-1725729303792.png

Viki_Nodejs_2-1725729422452.png

Thank you..

 

 

 

6 REPLIES 6

avatar
New Contributor

Adding message Tags to reach better view to get answer

avatar
Community Manager

@Viki_Nodejs, Welcome to our community! To help you get the best possible answer, I have tagged our Hive experts @asish @smruti  who may be able to assist you further.

Please feel free to provide any additional information or details about your query. We hope that you will find a satisfactory solution to your question.



Regards,

Vidya Sargur,
Community Manager


Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Learn more about the Cloudera Community:

avatar
Master Collaborator

@Viki_Nodejs It seems like the hostname resolution fails. The url you have shared is rather jdbc compliant. 

Could you give the following a try?

client.connect(
  {
    host: 'abc.com',
    port: 2181
  },
  new hive.connections.HttpConnection({
    transportMode: 'http', 
    httpPath: 'cliservice',
    serviceDiscoveryMode: 'zooKeeper', 
    zooKeeperNamespace: 'hiveserver2'
  }),
  new hive.auth.PlainHttpAuthentication({
    username: 'username',
    password: 'password'
  }),
  {
    ssl: true,
    sslTrustStore: '/etc/hive-jks/hivetrust.jks',
    trustStorePassword: 'pro@!23'
  }
).then(async client => {

 

avatar
New Contributor

Hi Smruti,

Thanks for your reply. I've used the above snippet. PFB Error

Viki_Nodejs_0-1725949707191.png

 

avatar
Master Collaborator

Do we get this error after it gets connected? Could there be a socket timeout error set at client side? I am not aware if the hive driver has a default timeout value. 
Instead of ZooKeeper, could you try connecting to HS2 directly.
e.g.
host: "hs2 node fqdn"
port: 10001

Remove
serviceDiscoveryMode: 'zooKeeper',
zooKeeperNamespace: 'hiveserver2'

avatar
New Contributor

@Viki_Nodejs 
Hi Viki, were you able to resolve the issue. I am also encountering same issue