Connecting Kdb server in node js

https://learninghub.kx.com/forums/topic/connecting-kdb-server-in-node-js

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".

Can you please share your code?

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);

});

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?