Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
justin_morley
Creator
Creator

Accessing Engine API in Qlik Sense Desktop from Node.js

Hi,

I have a Node.js solution which I've developed which uses the Engine API, wrapped by the marvellous Enigma.js, connecting to a QAP server instance to build and delete new apps on the fly according to given criteria.

It's all working beautifully in this environment.

Today I tried to port this to my laptop so I could 1) Develop on the move and 2) Show off the rather exciting possibilities such a solution offers. However I hit snags around authentication. My laptop has Desktop on it, not any of the Server versions.

Is it actually possible to do this - Node.js talking to Qlik Sense Desktop - or is this restricted? The configuration I pass to Enigma is included below. What needs to be different to connect to Qlik Sense Desktop?

{

  schema: qixSchema,

  session: {

      unsecure: false,

      host: qConfig.hostName,

      port: qConfig.QlikServicePort

    },

    createSocket: (url) => {

      return new WebSocket(url, {

        origin: qConfig.hostPrefix + qConfig.hostName,

        cert: fs.readFileSync(qConfig.certDir + qConfig.certPem),

        key: fs.readFileSync(qConfig.certDir + qConfig.keyPem),

        headers: {

          'X-Qlik-User': qConfig.header + qConfig.QlikServiceDirectory + qConfig.middle + qConfig.QlikServiceUser

        },

        rejectUnauthorized: false

      });

  }

2 Replies
websy1985
Luminary Alumni
Luminary Alumni

Hi Justin,

Connecting to Qlik Sense Desktop should be fairly straight forward, you just need to change your config to something like this:

config: {
  unsecure: true, 
  host: "localhost",
  port: 4848
}

You also don't need the certs in your connection as Desktop doesn't require any authentication and, lastly, your node server needs to be running on localhost as Sense Desktop won't accept connections from anywhere else. Given your description above I imagine that that's the case anyway.

In theory that should be it.

I hope that helps.

justin_morley
Creator
Creator
Author

Hi Nick,

Thanks for your reply.

Because I'm running Enigma from Node.js and not a browser, it crashes with this:

TypeError: this.createSocket is not a function

    at RPC.open (C:\temp\QAPService\QAPService\node_modules\enigma.js\dist\enig

a.js:2372:29)

What should my createSocket function look like?

Thanks