<?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>topic Re: Using Enigma to connect to QIX from remote machine in Integration, Extension &amp; APIs</title>
    <link>https://community.qlik.com/t5/Integration-Extension-APIs/Using-Enigma-to-connect-to-QIX-from-remote-machine/m-p/2019590#M17832</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/145804"&gt;@alex_colombo&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Thanks for your reply.&amp;nbsp; I am looking at ways of developing lighter-weight&amp;nbsp; mashups (using enigma and nebula rather than Capability API) on a local PC rather than directly through the dev-hub on one of our Qlik Sense Enterprise servers.&amp;nbsp; All of the examples I have seen seem to be based on the assumption that the development is being carried out on the server or where Qlik Sense Desktop is installed.&amp;nbsp; I would like to code in Visual Studio rather than the dev-hub.&lt;/P&gt;
&lt;P&gt;Could you point me towards any documentation that provides an end-to-end example of how to achieve this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 23 Dec 2022 08:53:53 GMT</pubDate>
    <dc:creator>rbartley</dc:creator>
    <dc:date>2022-12-23T08:53:53Z</dc:date>
    <item>
      <title>Using Enigma to connect to QIX from remote machine</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Using-Enigma-to-connect-to-QIX-from-remote-machine/m-p/2019229#M17821</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;
&lt;P&gt;Up until now, I have developed mashups and extensions directly on a Qlik Sense Enterprise server using the dev-hub. However, I would like to use Visual Studio from my own PC where I have no Qlik Sense elements installed.&amp;nbsp; So far, I have installed Node.js and Enigma.js on my PC and have followed the example here&amp;nbsp;&lt;A href="https://github.com/qlik-oss/enigma.js/" target="_self"&gt;https://github.com/qlik-oss/enigma.js/&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;const enigma = require('enigma.js');
const WebSocket = require('ws');
const schema = require('enigma.js/schemas/12.20.0.json');

// create a new session:
const session = enigma.create({
  schema,
  url: 'ws://localhost:9076/app/engineData',
  createSocket: url =&amp;gt; new WebSocket(url),
});

// bind traffic events to log what is sent and received on the socket:
session.on('traffic:sent', data =&amp;gt; console.log('sent:', data));
session.on('traffic:received', data =&amp;gt; console.log('received:', data));

// open the socket and eventually receive the QIX global API, and then close
// the session:
session.open()
  .then((/*global*/) =&amp;gt; console.log('We are connected!'))
  .then(() =&amp;gt; session.close())
  .then(() =&amp;gt; console.log('Session closed'))
  .catch(err =&amp;gt; console.log('Something went wrong :(', err));&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I replaced the localhost in the code above with the hostname of the Qlik Sense Enterprise server , but when I run the code I receive a timeout error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Something went wrong &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; ErrorEvent {
  [Symbol(kTarget)]: WebSocket {
    _events: [Object: null prototype] {
      open: [Function],
      close: [Function],
      error: [Function],
      message: [Function]
    },
    _eventsCount: 4,
    _maxListeners: undefined,
    _binaryType: 'nodebuffer',
    _closeCode: 1006,
    _closeFrameReceived: false,
    _closeFrameSent: false,
    _closeMessage: &amp;lt;Buffer &amp;gt;,
    _closeTimer: null,
    _extensions: {},
    _paused: false,
    _protocol: '',
    _readyState: 3,
    _receiver: null,
    _sender: null,
    _socket: null,
    _bufferedAmount: 0,
    _isServer: false,
    _redirects: 0,
    _url: 'ws://xxx.xxx.aws.cloud.tech.ec.europa.eu:9076/app/engineData',
    _req: null,
    [Symbol(kCapture)]: false
  },
  [Symbol(kType)]: 'error', 
[Symbol(kError)]: Error: connect ETIMEDOUT XX.XXX.XXX.XX:9076
      at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1300:16) {
    errno: -4039,
    code: 'ETIMEDOUT',
    syscall: 'connect',
    address: 'XX.XXX.XXX.XX',
    port: 9076
  },
  [Symbol(kMessage)]: 'connect ETIMEDOUT XX.XXX.XXX.XX:9076'&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this an authentication issue or is it just not possible to do what I am attempting?&amp;nbsp;&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;
&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>Thu, 22 Dec 2022 09:05:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Using-Enigma-to-connect-to-QIX-from-remote-machine/m-p/2019229#M17821</guid>
      <dc:creator>rbartley</dc:creator>
      <dc:date>2022-12-22T09:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using Enigma to connect to QIX from remote machine</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Using-Enigma-to-connect-to-QIX-from-remote-machine/m-p/2019251#M17822</link>
      <description>&lt;P&gt;It seems as though authentication is required.&amp;nbsp; I installed the pem certificates in my user folder and created a file based on the code here:&amp;nbsp;&lt;A href="https://github.com/qlik-oss/enigma.js/tree/master/examples/authentication/sense-using-certificates" target="_self"&gt;https://github.com/qlik-oss/enigma.js/tree/master/examples/authentication/sense-using-certificates&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This communicates on port 4747 rather than 9076, so as soon as 4747 had been opened, I was able to connect, create a session and retrieve the list of apps available to my user.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2022 10:12:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Using-Enigma-to-connect-to-QIX-from-remote-machine/m-p/2019251#M17822</guid>
      <dc:creator>rbartley</dc:creator>
      <dc:date>2022-12-22T10:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: Using Enigma to connect to QIX from remote machine</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Using-Enigma-to-connect-to-QIX-from-remote-machine/m-p/2019365#M17826</link>
      <description>&lt;P&gt;I have tried to do the same through a browser using the code below:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;&amp;lt;script src="https://unpkg.com/enigma.js/enigma.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.5/require.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script&amp;gt;
const path = require('path');
const fs = require('fs');


	// The Sense Enterprise-configured user directory for the user you want to identify
// as:
const userDirectory = 'xxxx';

// The user to use when creating the session:
const userId = 'xxxx';
const readCert = (filename) =&amp;gt; fs.readFileSync(path.resolve(__dirname, certificatesPath, filename));

 fetch('https://unpkg.com/enigma.js/schemas/12.34.11.json')
    .then(response =&amp;gt; response.json())
    .then(schema =&amp;gt; {
      const session = enigma.create({
        schema,
        // Change the url to point to your QIX instance
        url: 'wss://xxxxx.s4dad.aws.cloud.tech.ec.europa.eu:4747/app/engineData',
        createSocket: url =&amp;gt; new WebSocket(url,{
			ca: [readCert('root.pem')],
			key: readCert('client_key.pem'),
			cert: readCert('client.pem'),
			headers: {
			  'X-Qlik-User': `UserDirectory=${encodeURIComponent(userDirectory)}; UserId=${encodeURIComponent(userId)}`,
			},
		  })
      })

      session.open()
        .then(global =&amp;gt; global.engineVersion())
        .then(result =&amp;gt; document.body.innerHTML = result.qComponentVersion)
        .then(() =&amp;gt; session.close())
    });

&amp;lt;/script&amp;gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but haven't been able to figure out yet how to pass the certificate parameter.&amp;nbsp; The code above generates an error:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Uncaught Error: Module name "path" has not been loaded yet for context: _. Use require([])
http://requirejs.org/docs/errors.html#notloaded
    at makeError (require.min.js:1:1067)
    at Object.o [as require] (require.min.js:1:11053)
    at requirejs (require.min.js:1:14737)
    at index.html:4:14&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2022 13:26:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Using-Enigma-to-connect-to-QIX-from-remote-machine/m-p/2019365#M17826</guid>
      <dc:creator>rbartley</dc:creator>
      <dc:date>2022-12-22T13:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: Using Enigma to connect to QIX from remote machine</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Using-Enigma-to-connect-to-QIX-from-remote-machine/m-p/2019448#M17828</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/47074"&gt;@rbartley&lt;/a&gt;, that error happens because you are trying to run server side code on a client side. If you want to use enimga.js from a client I'd suggest to change apporach. First you have to change your authentication method. You could use &lt;A href="https://github.com/qlik-oss/enigma.js/tree/master/examples/authentication/sense-using-ticket" target="_blank"&gt;ticket &lt;/A&gt;or &lt;A href="https://github.com/qlik-oss/enigma.js/tree/master/examples/authentication/sense-using-jwt" target="_blank"&gt;JWT &lt;/A&gt;authentication. For both of them you need a server side component which will generate ticket or sign the JWT token. Then you can attach ticket or JWT token to websocket connection created by enigma.js on client side.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2022 16:25:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Using-Enigma-to-connect-to-QIX-from-remote-machine/m-p/2019448#M17828</guid>
      <dc:creator>alex_colombo</dc:creator>
      <dc:date>2022-12-22T16:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using Enigma to connect to QIX from remote machine</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Using-Enigma-to-connect-to-QIX-from-remote-machine/m-p/2019590#M17832</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/145804"&gt;@alex_colombo&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Thanks for your reply.&amp;nbsp; I am looking at ways of developing lighter-weight&amp;nbsp; mashups (using enigma and nebula rather than Capability API) on a local PC rather than directly through the dev-hub on one of our Qlik Sense Enterprise servers.&amp;nbsp; All of the examples I have seen seem to be based on the assumption that the development is being carried out on the server or where Qlik Sense Desktop is installed.&amp;nbsp; I would like to code in Visual Studio rather than the dev-hub.&lt;/P&gt;
&lt;P&gt;Could you point me towards any documentation that provides an end-to-end example of how to achieve this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Dec 2022 08:53:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Using-Enigma-to-connect-to-QIX-from-remote-machine/m-p/2019590#M17832</guid>
      <dc:creator>rbartley</dc:creator>
      <dc:date>2022-12-23T08:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: Using Enigma to connect to QIX from remote machine</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Using-Enigma-to-connect-to-QIX-from-remote-machine/m-p/2023553#M17881</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/47074"&gt;@rbartley&lt;/a&gt; there is no specific documentation this, and the reason is that it's a topic on pure dvelopments, indipendet from QlikSense. If you want to run mashup code outside dev-hub you need a local web server to run your code. An example could be to use a JS framework such as VueJs or React where you can their cli for running a project and a local webserver.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2023 08:22:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Using-Enigma-to-connect-to-QIX-from-remote-machine/m-p/2023553#M17881</guid>
      <dc:creator>alex_colombo</dc:creator>
      <dc:date>2023-01-10T08:22:04Z</dc:date>
    </item>
  </channel>
</rss>

