<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Couldn't establish Hive DB session in nodejs in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Couldn-t-establish-Hive-DB-session-in-nodejs/m-p/393265#M248406</link>
    <description>&lt;P&gt;Hi Smruti,&lt;/P&gt;&lt;P&gt;Thanks for your reply. I've used the above snippet. PFB Error&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Viki_Nodejs_0-1725949707191.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/41724iFCA3398B026A4CC0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Viki_Nodejs_0-1725949707191.png" alt="Viki_Nodejs_0-1725949707191.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Sep 2024 06:28:50 GMT</pubDate>
    <dc:creator>Viki_Nodejs</dc:creator>
    <dc:date>2024-09-10T06:28:50Z</dc:date>
    <item>
      <title>Couldn't establish Hive DB session in nodejs</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Couldn-t-establish-Hive-DB-session-in-nodejs/m-p/393187#M248363</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;
&lt;P&gt;Good Day..&lt;/P&gt;
&lt;P&gt;I'm beginner in Node.JS trying to connect Hive DB&amp;nbsp; using&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&lt;STRONG&gt;hive-driver npm&lt;/STRONG&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;from Node.JS code.&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;I couldn't establish the db connection.&lt;/P&gt;
&lt;P&gt;Any help would be much appreciated...&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Note: Our Hive DB has ssl connection, jks trust store password, HTTP protocol , httppath=cliservice&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;NODE.JS&amp;nbsp; SAMPLE CODE:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;client.connect(&lt;BR /&gt;{&lt;BR /&gt;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',&lt;BR /&gt;port: 2181&lt;BR /&gt;},&lt;BR /&gt;new hive.connections.HttpConnection(),&lt;BR /&gt;new hive.auth.PlainHttpAuthentication({&lt;BR /&gt;username: 'username',&lt;BR /&gt;password: 'password'&lt;BR /&gt;})&lt;BR /&gt;).then(async client =&amp;gt; {&lt;/P&gt;
&lt;P&gt;console.log(client);&lt;/P&gt;
&lt;P&gt;const session = await client.openSession({&lt;BR /&gt;client_protocol: TCLIService_types.TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V10&lt;BR /&gt;});&lt;/P&gt;
&lt;P&gt;}).catch(error =&amp;gt; {&lt;BR /&gt;console.log(error);&lt;BR /&gt;});&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;when I console.log client It's printing but I tried to open client.open session I've been facing issues&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kindly check the host url string&amp;nbsp; which I've given right or not.&lt;/P&gt;
&lt;P&gt;Could you please help on this issue.&lt;/P&gt;
&lt;P&gt;PFB Error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Viki_Nodejs_0-1725729303792.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/41701i785881A45A3CF4EB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Viki_Nodejs_0-1725729303792.png" alt="Viki_Nodejs_0-1725729303792.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Viki_Nodejs_2-1725729422452.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/41703i800358856E4D8ECF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Viki_Nodejs_2-1725729422452.png" alt="Viki_Nodejs_2-1725729422452.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Thank you..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Sep 2024 06:47:09 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Couldn-t-establish-Hive-DB-session-in-nodejs/m-p/393187#M248363</guid>
      <dc:creator>Viki_Nodejs</dc:creator>
      <dc:date>2024-09-09T06:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: Couldn't establish Hive DB session in nodejs</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Couldn-t-establish-Hive-DB-session-in-nodejs/m-p/393189#M248365</link>
      <description>&lt;P&gt;Adding message Tags to reach better view to get answer&lt;/P&gt;</description>
      <pubDate>Sun, 08 Sep 2024 08:44:41 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Couldn-t-establish-Hive-DB-session-in-nodejs/m-p/393189#M248365</guid>
      <dc:creator>Viki_Nodejs</dc:creator>
      <dc:date>2024-09-08T08:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: Couldn't establish Hive DB session in nodejs</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Couldn-t-establish-Hive-DB-session-in-nodejs/m-p/393202#M248372</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/116077"&gt;@Viki_Nodejs&lt;/a&gt;,&amp;nbsp;Welcome to our community! To help you get the best possible answer, I have tagged our Hive experts&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/71090"&gt;@asish&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/82698"&gt;@smruti&lt;/a&gt;&amp;nbsp;&amp;nbsp;who may be able to assist you further.&lt;BR /&gt;&lt;BR /&gt;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.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Sep 2024 06:46:41 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Couldn-t-establish-Hive-DB-session-in-nodejs/m-p/393202#M248372</guid>
      <dc:creator>VidyaSargur</dc:creator>
      <dc:date>2024-09-09T06:46:41Z</dc:date>
    </item>
    <item>
      <title>Re: Couldn't establish Hive DB session in nodejs</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Couldn-t-establish-Hive-DB-session-in-nodejs/m-p/393208#M248374</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/116077"&gt;@Viki_Nodejs&lt;/a&gt;&amp;nbsp;It seems like the hostname resolution fails. The url you have shared is rather jdbc compliant.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you give the following a try?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;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 =&amp;gt; {&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Sep 2024 07:36:05 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Couldn-t-establish-Hive-DB-session-in-nodejs/m-p/393208#M248374</guid>
      <dc:creator>smruti</dc:creator>
      <dc:date>2024-09-09T07:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: Couldn't establish Hive DB session in nodejs</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Couldn-t-establish-Hive-DB-session-in-nodejs/m-p/393265#M248406</link>
      <description>&lt;P&gt;Hi Smruti,&lt;/P&gt;&lt;P&gt;Thanks for your reply. I've used the above snippet. PFB Error&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Viki_Nodejs_0-1725949707191.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/41724iFCA3398B026A4CC0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Viki_Nodejs_0-1725949707191.png" alt="Viki_Nodejs_0-1725949707191.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2024 06:28:50 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Couldn-t-establish-Hive-DB-session-in-nodejs/m-p/393265#M248406</guid>
      <dc:creator>Viki_Nodejs</dc:creator>
      <dc:date>2024-09-10T06:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: Couldn't establish Hive DB session in nodejs</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Couldn-t-establish-Hive-DB-session-in-nodejs/m-p/393289#M248422</link>
      <description>&lt;P&gt;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.&amp;nbsp;&lt;BR /&gt;Instead of ZooKeeper, could you try connecting to HS2 directly.&lt;BR /&gt;e.g.&lt;BR /&gt;host: "hs2 node fqdn"&lt;BR /&gt;port: 10001&lt;BR /&gt;&lt;BR /&gt;Remove&lt;BR /&gt;serviceDiscoveryMode: 'zooKeeper',&lt;BR /&gt;zooKeeperNamespace: 'hiveserver2'&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2024 13:25:00 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Couldn-t-establish-Hive-DB-session-in-nodejs/m-p/393289#M248422</guid>
      <dc:creator>smruti</dc:creator>
      <dc:date>2024-09-10T13:25:00Z</dc:date>
    </item>
    <item>
      <title>Re: Couldn't establish Hive DB session in nodejs</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Couldn-t-establish-Hive-DB-session-in-nodejs/m-p/393972#M248632</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/116077"&gt;@Viki_Nodejs&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Hi Viki, were you able to resolve the issue. I am also encountering same issue&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2024 19:11:13 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Couldn-t-establish-Hive-DB-session-in-nodejs/m-p/393972#M248632</guid>
      <dc:creator>sravansrk</dc:creator>
      <dc:date>2024-09-25T19:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: Couldn't establish Hive DB session in nodejs</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Couldn-t-establish-Hive-DB-session-in-nodejs/m-p/398914#M250340</link>
      <description>&lt;P&gt;Hi sravansrk,&lt;/P&gt;&lt;P&gt;Still, the same issue persists.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2024 09:30:57 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Couldn-t-establish-Hive-DB-session-in-nodejs/m-p/398914#M250340</guid>
      <dc:creator>Vicky_node</dc:creator>
      <dc:date>2024-12-16T09:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: Couldn't establish Hive DB session in nodejs</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Couldn-t-establish-Hive-DB-session-in-nodejs/m-p/398989#M250355</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/116077"&gt;@Viki_Nodejs&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;FONT size="4"&gt;if you haven't resolved this issue could you try the below steps and revert.&lt;/FONT&gt;&lt;/P&gt;&lt;H3&gt;&lt;FONT size="4"&gt;&lt;STRONG&gt;1. Install the Required NPM Packages&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H3&gt;&lt;P&gt;Use the hive-driver package for Node.js, which supports HiveServer2 over HTTP/HTTPS.&lt;/P&gt;&lt;LI-SPOILER&gt;npm install hive-driver&lt;/LI-SPOILER&gt;&lt;H3&gt;&lt;FONT size="4"&gt;&lt;STRONG&gt;2. Prerequisites&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H3&gt;&lt;P&gt;Ensure you have:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;HiveServer2 URL&lt;/STRONG&gt;: Includes the hostname and port.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;SSL Configuration&lt;/STRONG&gt;: Paths to your .jks trust store and its password.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Hive httppath&lt;/STRONG&gt;: Set to cliservice.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Authentication details&lt;/STRONG&gt; (if required): Username/password or Kerberos configuration.&lt;/LI&gt;&lt;/UL&gt;&lt;H3&gt;&lt;FONT size="4"&gt;&lt;STRONG&gt;3. Configure the Connection&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H3&gt;&lt;P&gt;Here's an example of how to set up the connection using the hive-driver:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-SPOILER&gt;&lt;P&gt;const { HiveClient, TCLIServiceTypes } = require('hive-driver');&lt;/P&gt;&lt;P&gt;async function connectToHive() {&lt;BR /&gt;const client = new HiveClient(TCLIServiceTypes);&lt;/P&gt;&lt;P&gt;// Configure the Hive connection&lt;BR /&gt;const connection = client.connect({&lt;BR /&gt;host: '&amp;lt;HIVE_SERVER_HOSTNAME&amp;gt;', // e.g., hive.example.com&lt;BR /&gt;port: 10001, // HiveServer2 port, typically 10001 for HTTPS&lt;BR /&gt;options: {&lt;BR /&gt;path: '/cliservice', // HTTP path to HiveServer2&lt;BR /&gt;ssl: true, // Enable SSL&lt;BR /&gt;sslOptions: {&lt;BR /&gt;rejectUnauthorized: true, // Ensure certificates are verified&lt;BR /&gt;ca: '&amp;lt;path/to/truststore.pem&amp;gt;' // Convert your JKS truststore to PEM format&lt;BR /&gt;},&lt;BR /&gt;// Authentication&lt;BR /&gt;username: '&amp;lt;YOUR_USERNAME&amp;gt;',&lt;BR /&gt;password: '&amp;lt;YOUR_PASSWORD&amp;gt;',&lt;BR /&gt;// You can add session configurations here&lt;BR /&gt;}&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;try {&lt;BR /&gt;// Open the connection&lt;BR /&gt;await connection.openSession();&lt;BR /&gt;console.log('Connected to Hive');&lt;/P&gt;&lt;P&gt;// Example query&lt;BR /&gt;const result = await connection.executeStatement('SELECT * FROM your_table LIMIT 10');&lt;BR /&gt;console.log(result);&lt;/P&gt;&lt;P&gt;// Close the session&lt;BR /&gt;await connection.closeSession();&lt;BR /&gt;} catch (error) {&lt;BR /&gt;console.error('Error connecting to Hive:', error);&lt;BR /&gt;} finally {&lt;BR /&gt;// Ensure the connection is closed&lt;BR /&gt;await connection.close();&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;connectToHive();&lt;/P&gt;&lt;/LI-SPOILER&gt;&lt;H3&gt;&lt;FONT size="4"&gt;&lt;STRONG&gt;4. &lt;FONT color="#FF0000"&gt;Key Point to Note !!!!!!!!!&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H3&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;SSL Truststore [Very Important]&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Hive uses .jks files for its truststore, but hive-driver requires a .pem file for SSL. Convert your .jks file to .pem using the following commands:&lt;BR /&gt;&lt;LI-SPOILER&gt;keytool -importkeystore -srckeystore truststore.jks -destkeystore truststore.p12 -deststoretype PKCS12 openssl pkcs12 -&lt;SPAN class="hljs-keyword"&gt;in&lt;/SPAN&gt; truststore.p12 -out truststore.pem -nokeys&lt;/LI-SPOILER&gt; I also saw an&lt;SPAN&gt;&amp;nbsp;EAI_FAIL&amp;nbsp; error in the screenshot this is related to not being able to resolve the DNS.&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;Hope this helps&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Tue, 17 Dec 2024 18:14:15 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Couldn-t-establish-Hive-DB-session-in-nodejs/m-p/398989#M250355</guid>
      <dc:creator>Shelton</dc:creator>
      <dc:date>2024-12-17T18:14:15Z</dc:date>
    </item>
  </channel>
</rss>

