KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums kdb+ Connecting Kdb server in node js

  • Connecting Kdb server in node js

    Posted by Saidharsan on October 1, 2024 at 12:10 pm

    Hi, I am trying to connect kdb server from node js and end up with issues. Can you please provide some guidance on how to do it. I’ve used node-q and jkdb but still getting issues like “Error: getaddrinfo ENOTFOUND” or “Error: cb”.

    pgyorok replied 4 days ago 2 Members · 3 Replies
  • 3 Replies
  • pgyorok

    Member
    October 1, 2024 at 12:19 pm

    Can you please share your code?

  • Saidharsan

    Member
    October 3, 2024 at 4:25 am

    Below is for jkdb

    const { QConnection } = require(“jkdb”);

    const q = new QConnection({ host : “Office_Server_URL”,port: 5000, user: “user”, password: “password” });

    q.connect((err) => {

    if (err) throw err;

    console.log(“connected”);

    // send query from here

    });


    Below is for node-q

    const q = require(‘node-q’);

    const connectionDetails = {

    host : ‘Office_Server_URL’,

    port : 5000,

    user : ‘username’,

    password : ‘password’};

    q.connect(connectionDetails)

    .then((conn) => {

    return conn.k(’til 3′);

    })

    .then ((result) => {

    console.log(‘res : ‘+result);

    q.disconnect();

    })

    .catch((err) => {

    console.log(‘Error : ‘+err);

    });

  • pgyorok

    Member
    October 3, 2024 at 9:25 am

    Unfortunately I’m not familiar with the library code, but “getaddrinfo ENOTFOUND” would indicate that the host name that you provided is incorrect. If this is appearing consistently, check if the host name is correct. If it’s intermittent, you might have a problem with the DNS in your environment.

    For the “cb” error, it could either come from the connection library or be returned as an error message from the server. Can you try to connect using a plain q process to see if you get the same error? It might be coming from the client query handlers that try to access a variable named “cb” when it’s not defined – do you have handlers such as .z.ps and .z.pg set on the server?

Log in to reply.