Created on 09-07-2024 10:25 AM - last edited on 09-08-2024 11:47 PM by VidyaSargur
Hi Team,
Good Day..
I'm beginner in Node.JS trying to connect Hive DB using
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.
Thank you..
Created 09-08-2024 01:44 AM
Adding message Tags to reach better view to get answer
Created 09-08-2024 11:46 PM
@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,Created 09-09-2024 12:36 AM
@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 => {
Created 09-09-2024 11:28 PM
Hi Smruti,
Thanks for your reply. I've used the above snippet. PFB Error
Created 09-10-2024 06:25 AM
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'
Created 09-25-2024 12:11 PM
@Viki_Nodejs
Hi Viki, were you able to resolve the issue. I am also encountering same issue